x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.14
Tags:
more ▼

asked Nov 24 '16 at 09:11 PM in C++ Programming

avatar image

haimat
226 20 34 42

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

So as I found out all you need to do is to enable the following flag in the .Build.cs file (within the constructor):

 BuildConfiguration.bAllowLTCG = true;

This enables the /LTCG flag for Shipping builds.
Cheers!

more ▼

answered Nov 25 '16 at 11:56 AM

avatar image

haimat
226 20 34 42

(comments are locked)
10|2000 characters needed characters left

Hi !

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.

more ▼

answered Nov 25 '16 at 08:30 AM

avatar image

NymKappa
692 31 20 53

avatar image haimat Nov 25 '16 at 11:57 AM

Thanks. I have however found another solution, which works without recompiling the UBT. See my (accepted) answer to this question.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question