"Correct" way of compiling C++ UE Projects

Is there a “correct” optimal way of compiling Unreal C++ Code?

image
image

Because I used to press the build button in Visual Studio and let Unreal auto compile the code.
Sometimes pressing build in Visual Studio doesn’t trigger the reload so I manually press the “Compile” button inside Unreal.

People have said that the Compile button from Unreal doesn’t actually Compile. What does it do then? :thinking:

Some renowned Unreal Slackers DiscordCcommunity members have criticized the approach above and written popular articles about how the method above is known to corrupt Blueprints.

So I have switched for the live coding method by launching the Engine trough Visual Studio Debugging.
image
Which is also known to cause possible issues and not correctly reload/recompile the code. Their recommendation is to always close the engine before compiling code.

What is the “correct” optimal way of coding C++ for Unreal then?
This got me completely confused about what Building, Rebuilding and Compiling actually mean.

Are you sure you didn’t accidentally change the configuration?
image

Huh? Of course it does; but with the project open in the editor, regardless where you build it from, has to do something different than it normally would (overwrite the .dll) as it’s currently loaded in memory and the OS isn’t going to let you do that.

That’s not Live Coding which is a method of being able to compile with the project currently open. By compiling a new .dll and patching the existing one.
It also appears that you are using UE4; Live Coding was introduced in 4.22 as experimental with a limited features than it does currently (you couldn’t modify header files with it back then IIRC) and IIRC was made the default method (replacing HotReload) in 5.0. You’d have to enable in your editor preferences otherwise.

I’ve not seen any particular issues like that (regarding actual Live Coding and not what you described). Though due to how it works whenever you close Unreal you should build the project so that it can overwrite the existing .dll and delete the old patch .dlls.

1 Like

Thanks for the answers.
When I launch Unreal trough Visual Studio Debugging this pops up.

For some strange reason, it didn’t register some new vars I added to the code until I restarted the editor.

Guess that such a thing like “correct” optimal way doesn’t exist in this context. If the game works, then it works.
I suppose both methods are prone to possible bugs and corruptions.

At least now I know that when the code is correct but not working, all I gotta do is restart Unreal.

That screenshot shows that you are using DebugGame which is not you load when you double click on the .uproject in File Explorer or open with the UE4Editor, you need to switch to Development Editor as shown in my screenshot.

They were called something slightly different in UE4 but:
image

When you load the project using the Epic Games Launcher or double clicking the .uproject that launches the UnrealEditor.exe which when you open the project would load UnrealEditor-ProjectName.dll.

You are using the DebugGame configuration so that will launch UnrealEditor-Win64-DebugGame.exe (slightly different name in UE4) and that loads UnrealEditor-ProjectName-Win64-DebugGame.dll

So when you’ve been building in VS, since you’re using the DebugGame Editor configuration you are building a completely different .dll to which the Unreal Editor will load and which is why you are not seeing the changes.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms