How to set linker flags (/LTCG)?
I am using a static library (.lib) in my UE4 project. That basically works fine, however, I get the following warning during compilation:
"MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance"
Now according to MSDN this problem is based on the fact that the library is compiled with the /GL flag turned on (= Whole Program Optimization), but for the UE4 project the linker does not use the /LTCG flag (whereas both shoud be used or none).
So my question: How can I tell the linker in my UE4 project to use this /LTCG flag?
asked Nov 24 '16 at 09:11 PM in C++ Programming
So as I found out all you need to do is to enable the following flag in the .Build.cs file (within the constructor):
This enables the /LTCG flag for Shipping builds.
answered Nov 25 '16 at 11:56 AM
If you want to change the linker flag, you have to rebuild UnrealBuildTool from source. You can download it from the git repository.
Open the CVToolChain.cs file and there you will find all command line parameters used with cl.exe. Just add your linker flag at the proper spot (according to your build configurations needs).
Then just rebuild the UE4 target from your project's Visual Studio Solution and the changes will be applied.
To make sure you linker flag has been taken in account, I suggest you add "–verbose" to your NMake parameters (right click on your project target, properties, NMake).
Good luck ! Best regards.
answered Nov 25 '16 at 08:30 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here