Failed to build UE4 from source - error C4426: optimization flags

Hi,

I got following error during building UE4.11p5 from source at VS2015 Community Update 1:

1> Module.GameplayTasks.cpp
1> Module.GameplayAbilitiesEditor.cpp
1>c:\GIT\UnrealEngine\Engine\Source\Runtime\GameplayTasks\Private\GameplayTask.cpp(3): error C4426: optimization flags changed after including header, may be due to #pragma optimize()c:\GIT\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Inc\GameplayTasks\GameplayTasks.generated.cpp(8): error C4426: optimization flags changed after including header, may be due to #pragma optimize()
1>
1>c:\GIT\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\GameplayTasks\Module.GameplayTasks.cpp(3): error C4426: optimization flags changed after including header, may be due to #pragma optimize()
1>c:\GIT\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Development\GameplayAbilitiesEditor\Module.GameplayAbilitiesEditor.cpp(21): error C4426: optimization flags changed after including header, may be due to #pragma optimize()
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: c:\GIT\UnrealEngine\Engine\Binaries\Win64\UE4Editor-GameplayTasks.dll

Do you have any idea how to resolve it ?

Hello,

  • What operating system are you using?
  • Did you make any changes to source, or are you attempting to build it for the first time?
  • Does this only occur with 4.11 Preview source builds?
  • Are you able to build C++ projects in a non-source version of the engine?

Hello,

I am marking this topic as resolved for tracking purposes, as we have not heard from you in a few days. If this issue persists, feel free to respond to this thread. For any new issues, please create a new Answerhub topic.

Have a great day

I can confirm this issue on current master and promoted branches. It is directly related to breaking changes introduced in VS2015 Update 1 that are explained here Visual C++ What's New 2003 through 2015 | Microsoft Docs (#pragma optimize() extends past end of header file). The VS2013 compilation is unaffected and works without problems.

Thank You, I confirm that problem is solved (verified in UE4.11p7) :slight_smile:

Have a great day

We’re hitting the same thing, but only in one configuration; we clearly grabbed our latest drop a bit too early.

What was the specific fix for this? Was it a change to the core macros and/or compilation settings, or were there some engine headers that were leaking optimize settings which have now been cleaned up?

Cheers,

Having this issue myself now as well. 4.12.4. It was fine when I was in “Development Editor”,but switching to “DebugGame Editor” now I am running into this issue.

Do you happen to be using Visual Studio 2015 Update 3? There was a fix for Update 3-related issues pushed into 4.12.5.

Could you provided the error messages you are seeing so I can take a closer look?

I just checked and we are actually using Update 1. Should I get systems to install a specific update?

Hi Sean,

EDIT: I was actually wrong. We are already using 4.12.5

Updated to Update 3 and still having this issue. We are currently on 4.12.4 and I don’t have the option in the short term of moving to 4.12.5. We are longer term (in the next few weeks) going to move to 4.13 but I have bugs I need to get fixed in our tools now on 4.12.4

Is there any information on what I can change in 4.12.4 to get this to compile? I really need proper debugging to track down a tricky bug.

The error is exactly as stated above: error C4426: optimization flags changed after including header, may be due to #pragma optimize()

Now interestingly the compiler is calling out one of OUR files with this error, but I assume it is simply a carry over from something we are including since we aren’t doing anything special in our files.