Compiling erorr: All source files in module "Breathe" must include the same precompiled header first

Hello, I keep getting this error everytime I compile with Visual Studio once I add a character to my project. I’ve tried creating different projects but it happens on those too. This is the error:

error: All source files in module “Breathe” must include the same precompiled header first. Currently “C:\Users\User\Documents\Unreal Projects\Breathe\Source\Breathe\Breathe.h” is included by most of the source files the following source files are not including “C:\Users\User\Documents\Unreal Projects\Breathe\Source\Breathe\Breathe.h” as their first include: C:\Users\User\Documents\Unreal Projects\Breathe\Intermediate\ProjectFiles\EXEC Breathe

I’ve tried searching but haven’t found a solution that has worked so far.
Thanks in advance.

Basically the first #include in each .cpp file in your project has to be .h. So if your project is called Breathe make sure that the first include is “Breathe.h”.

What’s actually happening is that file is being used as a pre-compiled header. If you have some header you find your including a lot you can place it in this file to decrease compile times. UE4 requires the same pre-compiled header to be used for each .cpp file in a module, in this case your game module. There’s a lot of good info on the web if you want to read up on pre-compiled headers otherwise just follow the advice above :slight_smile:

I have done that, however I still get this error.

Have you had a look at the file it mentions? It looks like something it’s generating might be wrong somehow, it’s weird that there’s a space in that file name. Did you create a C++ file with a space in it’s name?

It might be good if you could post the code for the file that you created that’s cased this.

The file it mentions doesn’t exist. What I did to make this happen is be in the unreal engine editor, click file then add code then select character and name it BreatheCharacter and then click create class, thats all I did and then this started happening when I tried to compile it.

Check if you have any additional files in source folder and delete them or include header.

I’ve checked they all include Breathe.h

Have you tried deleting the intermediate folder? Try deleting everything but the .uproject file and the config, content and source folders. Then right click on the .uproject and select generate project files. Then try again with a clean build.

Attempted to do that just now and it wouldn’t allow me to regenerate the files or launch with uneal engine, Im going to create a new project and see if it happens in that as well.

The same problem happens to me also. Finally it’s done.
What I do is to create a new empty C++ class, and I add a external header file in the project. Then it warns like that. The solution is to add the #include “%your project name.h” into the external .cpp file corresponding to the external header you add.
Hope it helps.

Make sure you have this line in your ( .build.cs ) file

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;