C++ - cross project engine builds

Hi there,

It seems that it’s possible for the C++ build environment to get projects mixed up. I have two C++ projects that I work on at the same time, one (UE4Cooker) just within the editor environment, the other (MM_04) standalone / editor depending on what I’m working on.

Compiling MM_04 DebugGame or Development builds I’m getting errors about PCH.UELinkerFixupsName.h

Opening the file it is referencing a file in the UE4Cooker project. This probably doesn’t exist because I’ve never built a Development / DebugGame build for the project.

File: C:\Program Files (x86)\Epic Games\4.11\Engine\Intermediate\Build\Win64\UE4\Development\UELinkerFixups\PCH.UELinkerFixupsName.h.cpp

Contents:
#include "D:\Projects\UE4Cooker\Intermediate\Build\Win64\UE4\Development\UELinkerFixupsName.h"

A clean and build fixes the problem but it seems like this file shouldn’t be in the shared engine development folder but one of the project specific subdirectories.

Hey -

Do you have both projects open inside Visual Studio at the same time? How are you building either project? Are you right clicking the project name and selecting Build or are you using the Build->Build Solution option from the menu bar (same as Ctrl+Shift+B). What is set as the default project in the solution explorer?

Cheers

Do you have both projects open inside Visual Studio at the same time?

  • Yes.

How are you building either project? Are you right clicking the project name and selecting Build or are you using the Build->Build Solution option from the menu bar (same as Ctrl+Shift+B).

  • Always Ctrl+Shift+B - except when the
    uproject is out of date when opening
    and asks if I want to build it (may
    have happened - I moved to 4.11
    yesterday).

What is set as the default project in the solution explorer?

  • UE4Cooker: DebugGame Editor, or Development Editor (always Editor builds).
  • MM_04: Typically either of the Editor builds but this morning I switched to the non edtior build which is when I got the compile error

Another aspect to this is that if I have the MM_04 editor open UE4Cooker creates hotreloads, even without it’s editor open.

When you say you have both projects open in VS at the same time do you mean both of them open in the same VS instance (both showing in the solution explorer) or do you have 2 instances of VS running, each one with one project in it? If you are using the first method, how are you opening VS with multiple projects? Can you let me know if you have the same build issues with non-UE4 projects?

Two different VS instances, each with a UE4 project open (UE4Cooker in one, MM_04 in the other).

Never had this problem before but it seems very tied to the UE4 build system - with project specific code going into a non project specific file:

C:\Program Files (x86)\Epic Games\4.11\Engine\Intermediate\Build\Win64\UE4\Development\UELinkerFixups\PCH.UELinkerFixupsName.h.cpp

Are you able to reproduce this using two new projects? I attempted to open the solution for two projects and change the code to ensure that both required a compile. I was able to compile (Ctrl+Shift+B) one and then the other with no issue at all. Are you attempting to compile both projects at the same time when you see this message? If so then a compile error is to be expected as Visual Studio can only support running a single compile process at a time.

I’m about 90% sure this is a UE4 issue not a visual studio problem, the file got into a state where it was referencing a build configuration that I’d never have used. Make that 95% sure.

Messing around with that cpp file by hand I can’t repro the compile errors, nor can I repro by deleting different directories on my two projects to try and cause the problem again. So I guess we may as well close it out and move on to more interesting issues.

However it still seems odd that this project specific file is being written to that directory - without knowing the build process it seems like it would make more sense for to go in the engine level project specific directories just around the corner:

C:\Program Files (x86)\Epic Games\4.11\Engine\Intermediate\Build\Win64\UE4\Development\UE4Cooker

Ha - got it again. Its not stopping me and I would assume a small number of end users will be effected, but I suspect there’s an easy fix for it. Good thing I’ve got a new computer - this would have eaten a lot more time doing the clean and build on my old one!

These are the compile errors - notice I’m linking MM_04 and its trying to link in UE4Cooker files:

1> Performing 1 actions (4 in parallel)
1> [1/1] Link MM_04.exe
1> Creating library C:\Users\ Shepherd\Documents\Unreal Projects\MM\Binaries\Win64\MM_04.lib and object C:\Users\ Shepherd\Documents\Unreal Projects\MM\Binaries\Win64\MM_04.exp
1>UELinkerFixups.cpp.obj : error LNK2019: unresolved external symbol “void __cdecl EmptyLinkFunctionForGeneratedCodeUE4Cooker(void)” (?EmptyLinkFunctionForGeneratedCodeUE4Cooker@@YAXXZ) referenced in function “void __cdecl UELinkerFixups(void)” (?UELinkerFixups@@YAXXZ)
1>UELinkerFixups.cpp.obj : error LNK2019: unresolved external symbol “void __cdecl EmptyLinkFunctionForStaticInitializationUE4Cooker(void)” (?EmptyLinkFunctionForStaticInitializationUE4Cooker@@YAXXZ) referenced in function “void __cdecl UELinkerFixups(void)” (?UELinkerFixups@@YAXXZ)
1>C:\Users\ Shepherd\Documents\Unreal Projects\MM\Binaries\Win64\MM_04.exe : fatal error LNK1120: 2 unresolved externals
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\ Shepherd\Documents\Unreal Projects\MM\Binaries\Win64\MM_04.exe
1> Total build time: 6.88 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3073: The command ““C:\Program Files (x86)\Epic Games\4.11\Engine\Build\BatchFiles\Build.bat” MM_04 Win64 Development “C:\Users\ Shepherd\Documents\Unreal Projects\MM\MM_04.uproject” -waitmutex” exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Did both projects have edits and require a compile? Do you get the same issue if you build UE4Cooker (does it try to build MM_04)? Is either project dependent on the other in any way? Do you have the same problem is you have two different projects open? Let me know if you can think of any other information that will help me reproduce this on my machine.

No cross links between the projects (beyond this file we’re talking about…). The UE4 Project has code in a plugin, and a little in its source directory so that the option to build Visual Studio files would work. MM04 has a lot of code in its Source directory. Today I haven’t built UE4Cooker except while I was trying (and failing) to repro this problem, then an hour later I did get the error while building MM_04 development build (not editor build).

There are no dependencies between the projects, though UE4Cooker is intended as an asset cooker for MM_04 there is no connection between them at all. No shared plugins, no shared code outside Unreal Engine code. No overlapping directories or dependencies on the location of each project.

I don’t use any other UE4 code projects on a regular basis. I do often have multiple Visual Studios open at a time, typically without issue. These days mostly C# tools and MM_04, UE4Cooker is a new addition and the first to cause issues.

Most of the directory structure seems very well setup for multiple projects at once, I suspect one of your build setup boffins could fix this one location pretty easily if they knew it could cause problems, it just looks like it’s in the wrong place.

I guess the hotreload issue I mentioned a few posts up points to a bit more cross project interference. To repro that I can open up the editor in any project (I tested with an empty, brand new this morning, non code project) and then do a compile in my UE4Cooker project with a change in the plugin code.

The UE4Cooker then does “Compiling game modules for hot reload”. Even though it’s own exe is not running. Perhaps this is expected but as I’m not changing any shared engine code it doesn’t seem needed and cost me some dev time before I realized why I wasn’t seeing my changes coming though.

Hey -

I was able to reproduce some Unresolved Externals errors when compiling two projects back and forth. I only managed to get this error after compiling both projects using DebugGame configuration. On a couple of occasions, if a project was not compiling due to these unresolved externals, replacing the name of the project in the file you mentioned with the name of the project I’m attempting to compile will allow it to compile. This is only a workaround and did not have 100% success in allowing the project to compile. This has been reported (UE-26639) for further investigation.

Cheers

Thanks ,

works - is a joke moniker going back a long way.

UE-26639 should have been fixed so that project intermediates won’t go into the engine folder anymore. Should be part of the next preview as long as it’s a CL later than 2864643.