How to compile C++ code faster?

Hey everyone!
I’ve just started to work with Unreal this week and a thing that is bothering me is that I’m constantly waiting 5 to 10 minutes to the engine to compile my code (event the smallest ones) when it have any modification.
Does anyone know how could I fix this? How could I make this compile time faster? Is it something retated to my setup?

Thanks in advance!

1 Like

That’s too long, shouldn’t be that way.
Look at the size of your Binaries folder. IDK about Visual Studio, but when you compile in the engine, it creates files in Binaries, and they pile up really quickly to dozens of gigabytes. You can safely delete them. Sometimes it helps to speed up compilation.

1 Like

How are you compiling? Maybe you’re re-building the entire solution each time?

It should only be building your changed files and maybe dependents… should only take a 5-10 seconds compiling a small change.

2 Likes

I’m compiling through the engine, maybe this Binaries solution works, I’ll test and update here later.

Thanks!

Look thru this thread… you might be having similar issues:

1 Like

By the way, each plugin has its own Binaries folder that grows too when you compile via the engine. You should clean them up as well from time to time.

2 Likes

What is your computer specs?
Modifying the h file will require the files which including the h file to recompile, you can move some code which you are experimenting to cpp file.
You can expose some variable to blueprint, so you can modify the value withou recompile.

1 Like

If the slow compilation times are in UE5 (noticed that this post is tagged as such), then this other thread could be related:

It seems that when compiling in UE5, fewer processes are created and/or the cpu isn’t being used at full capacity. This becomes obvious when comparing compilation performance between UE4 and UE5. Not sure yet if this is affecting all users, and whether or not this is a known issue by Epic. Hoping for an official response like “we are aware of this issue and it will be fixed in 5.0.2” or something along those lines.

1 Like

Have you seen this solution?
Speed up Unreal Engine compile time!

1 Like

As Hexavx said, modifying a header file requires everything to recompile. You should forward declare your classes in the header file and move all #include and method implementation to the cpp files. You should also use the Unity system by enabling it in your build.cs files of the project and plugins you want to compile. Other than this VS is just a slow old beast. Sometimes it can hang for 5 minutes “building tasks…” at which point I noticed aborting the build and cleaning the project first results in a faster next build. Your RAM usage should be kept as low as possible, if RAM is high you won’t be compiling quickly.

2 Likes