Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Cannot open source file "generated.h"

I can't include X.generated.h header file in my project. For some reason when I try to include the header file I get "Cannot open source file "X_generated.h". I've tired to generate Visual Studio project files, but didn't help. I've found this question https://answers.unrealengine.com/questions/740950/cannot-open-source-file-namegeneratedh.html about the same issue, but still couldn't resolve the problem. Any help would be greatly appreciated.

Product Version: UE 4.22
more ▼

asked Apr 24 '19 at 01:33 PM in Using UE4

avatar image

25 2 2 7

avatar image HarryHighDef Apr 24 '19 at 02:37 PM

Is it that last think you include in your header?

avatar image Bazzy2000 Apr 24 '19 at 03:11 PM

Yes, it is the last thing.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Try to clean your project.

  1. Close UE and VS

  2. Delete ".vs", "Binaries", "Intermediate" and "Saved" folders in your project root folder

  3. Double click your ".uproject" file and let the engine build everything.

  4. Generate VS files.

  5. Close the engine

  6. Open VS and recompile again

more ▼

answered Apr 25 '19 at 12:56 AM

avatar image

210 2 7 6

avatar image Bazzy2000 Apr 25 '19 at 05:27 AM

I've tried those steps before and didn't resolve the error, but I'll try again and let you know.

avatar image Bazzy2000 Apr 25 '19 at 07:17 AM

I tried your steps.

  • First thing is that when I double click .uproject, it doesn't build everything and asks me to build the project manually. So I tired to build the project manually but it still says "Cannot open source file "X_generated.h".

  • I've tested the header file with a project that already has the generated.h header file in it and it works without any problems, but whenever I try to add the generated.h file myself to my c++ code, it says "Cannot open source file "X_generated.h".

avatar image BrunoCaxito Apr 25 '19 at 02:57 PM

Not sure what is causing this issue. I think a possible workaround would be start again, removing the .h and .cpp files completelly from your project and source folder, you will probably have to comment every reference to this files and its classes through the project. Right click the .uproject file and generate Visual Studio project files.

Then, you should compile with VS, start the engine editor and recreate the file with "File > New C++ class". Paste the content back in the new files and recompile again. (using the autogenerated #includes)

avatar image Bazzy2000 May 02 '19 at 07:08 AM

Thank you all for you answers. I got the generated.h to work but its a bit buggy. By that I mean UE4 or VS sometimes works and sometimes doesn't. I created the .cpp and.h file for five times and got it finally to work.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question