C++ code not compiling

Hey answerhub!

I was just trying to compile a project but I noticed that my classes aren’t being showed in the editor and if I put an error in my code and compile, the compiler doesn’t pick up on it which makes me think that it is not compiling my project but only the UE4 source. Also when I launch the editor and click on “Compile C++” from the editor, it does nothing. Does anyone have a solution to this?

Thanks in advance!

Can you explain how have you created the project and how are you trying to compile?

I created the project with the unreal engine client and I am compiling with Visual Studio or the in-editor compiler.

I suspect you used VS add code function, which will generate code files inside intermediate directory where your VS project files are generated and somewhere where UBT don’t search for code files, you need to place them in Source directory (physiclly, not in “Source” directory in project listing). You need to use “Add Code To Project” in editor it will generate code fiels properly and will regenerate project files to include them (VS then usually ask you if you want to reload them as VS detect changes in them)

Most importent thing you need to understand working with C++ in UE4 is that UE4 don’t use VS at all other then compiler, it has it’s own build system called UBT and it ignores most things inside VS project files (most settings set up there are just for IntelliSence), VS is practically just used as text editor and you don’t even need to run VS to compile, you can just run UBT, in fact engine can detect code changes and it will ask you if you want to recompile them then you run editor. Thats what you see in VS might behave differently as you think

I +1 's answer:

If you’ve added classes outside of the Unreal Engine editor, they’d be in the Intermediate directory (folder) and you’ll have to move the header file to the Public subfolder and the cpp class file to the Private subfolder of your game’s project. It confused the hell out of me too for about a day or so lol.

Good luck mate. Hope that helps.

Yes I know, but I have added my classes via the in-editor “add code to project” and the GameMode class that was there from the beginning are all in the “Source” folder and they are not being compiled.

then you might picking wrong project or something?

So I tried to open the project via the launcher and now I get an error say “The following modules are missing or built with a different engine version …Would you like to rebuild them now?”. Then I click “Yes” and it says: “Project could not be compiled. Try rebuilding from source manually”.