[4.7.2] Cross Compile Linux Server

Hey,

a bug occurred which prevents my Linux Server Target from building on Windows. First some system specs:

My OS: Windows 8.1 Pro 64 bit

My Project: C++ (Based on Third Person Template)

My Toolchain: http://cdn.unrealengine.com/qfe/v4_clang-3.5.0_ld-2.24_glibc-2.12.2.zip (which is clang 3.5.0 for x86 based systems)

My Engine: Custom build from 4.7.2 release branch (GitHub) with following Changes:

Engine\Source\Programs\UnrealBuildTool\Linux\LinuxToolChain.cs:

Line 277:
                if (!CompileEnvironment.Config.bEnableExceptions)
                {
                    Result += " -fno-exceptions";               // no exceptions
                }

Line 288:
             Result += " -Wall"; //-Werror

Line 298:

            if (!CompileEnvironment.Config.bUseRTTI)
            {
                Result += " -fno-rtti";                 // no run-time type info
            }

Compiler Error

1>  In file included from D:\MyUnrealProjects\Git\Faudra\Intermediate\Build\Linux\x86_64-unknown-linux-gnu\FaudraServer\Development\Faudra\Faudra.h:4:
1>  In file included from D:\MyUnrealProjects\Git\Faudra\Source\Faudra\Public\Faudra.h:41:
1>  In file included from Runtime/Engine/Public\Engine.h:9:
1>  In file included from Runtime/Core/Public\Core.h:16:
1>  In file included from Runtime/Core/Public/HAL\PlatformIncludes.h:53:
1>  In file included from Runtime/Core/Public\Linux/LinuxPlatformIncludes.h:19:
1>Runtime/Core/Public\Linux/LinuxPlatformMath.h(61,55): error : use of undeclared identifier 'isfinite'; did you mean 'std::isfinite'?
1>          static FORCEINLINE bool IsFinite( float A ) { return isfinite(A); }
1>                                                               ^~~~~~~~
1>                                                               std::isfinite
1>  D:\UEToolChain/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1\cmath(582,3) :  note: 'std::isfinite' declared here
1>    isfinite(float __x)
1>    ^
1>  In file included from D:\MyUnrealProjects\Git\Faudra\Intermediate\Build\Linux\x86_64-unknown-linux-gnu\FaudraServer\Development\Faudra\Faudra.h:4:
1>  In file included from D:\MyUnrealProjects\Git\Faudra\Source\Faudra\Public\Faudra.h:41:
1>  In file included from Runtime/Engine/Public\Engine.h:22:
1>  In file included from Runtime/Engine/Public/EngineMinimal.h:15:
1>  In file included from Runtime/Engine/Classes\GameFramework/Character.h:5:
1>  In file included from Runtime/Engine/Classes\Animation/AnimationAsset.h:10:
1>  In file included from Runtime/Engine/Public\SkeletalMeshTypes.h:13:
1>  In file included from Runtime/Engine/Public/Components.h:5:
1>  In file included from Runtime/RenderCore/Public\RenderResource.h:10:
1>  In file included from Runtime/RHI/Public\RHI.h:1007:
1>  In file included from Runtime/RHI/Public/RHIResources.h:8:
1>D:\Unreal Sources\4.7\UnrealEngine\Engine\Source\Runtime/Engine/Public/PixelFormat.h(66,2): error : expected identifier
1>          PF_MAX                  =57,
1>          ^
1>  D:\UEToolChain/usr/include\bits/socket.h(112,17) :  note: expanded from macro 'PF_MAX'
1>  #define PF_MAX          37      /* For now..  */
1>                          ^

Additional Note

I am able to build Unreal Engine itself using that toolchain and these modifications just fine (getting UE4Server Linux Binary which is executable). However, if I try to compile my project, it fails.

Some things to note: My project links against a few other static libraries (boost 1.56.0 and some custom c++ libraries built by me - but since it’s not a linker error, I guess it isn’t that relevant here, is it?)

It turns out, that it had to do something with the order i included my headers. The problem was that I included the STL headers before I included Engine.h in my projects pch header.

After that, I am able to proceed to the linking process. However, now I get some linker errors:

1>  [2/2] Link FaudraServer
1>  D:/MyUnrealProjects/Git/Faudra/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/FaudraServer/Development/Faudra/FaudraCharacter.cpp.o:(.rodata+0x8b0): undefined reference to `typeinfo for ACharacter'
1>  D:/MyUnrealProjects/Git/Faudra/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/FaudraServer/Development/Faudra/FaudraGameInstance.cpp.o:(.rodata._ZTI19UFaudraGameInstance[_ZTI19UFaudraGameInstance]+0x10): undefined reference to `typeinfo for UGameInstance'
1>  D:/MyUnrealProjects/Git/Faudra/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/FaudraServer/Development/Faudra/FaudraGameMode.cpp.o:(.rodata._ZTI15AFaudraGameMode[_ZTI15AFaudraGameMode]+0x10): undefined reference to `typeinfo for AGameMode'
1>  D:/MyUnrealProjects/Git/Faudra/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/FaudraServer/Development/Faudra/FaudraLoginConnector.cpp.o:(.rodata+0x388): undefined reference to `typeinfo for UObject'
1>  D:/MyUnrealProjects/Git/Faudra/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/FaudraServer/Development/Faudra/Faudra.generated.cpp.o:(.rodata._ZTI9TPropertyIf16UNumericPropertyE[_ZTI9TPropertyIf16UNumericPropertyE]+0x18): undefined reference to `typeinfo for UNumericProperty'

I guess, the problem is that somehow RTTI is missing in my Unreal Engine build?

Edit Yep! RTTI was disabled for UE4 (Linux build) and thus there were linker errors. Now my server target (linux) links fine under windows :slight_smile: Just have to test if the executable is able to run.

Who accepted my own comment as an answer? ^^

Anyway: The Server does run now. Just want to bring all points together again.

  • To link against boost, I needed to enable exceptions and RTTI (as described above).
  • I had to make sure that the engine was compiled with RTTI enabled, too, so that there aren’t any link errors because of missing RTTI
  • I had to include the STL headers and the headers of my custom libraries AFTER I included Engine.h in my project so that I wouldn’t get strange compile errors
  • On Windows however, that won’t work, since boost (asio) includes Windows.h, which will again cause compiler errors if Windows.h is included before Engine.h (something about INT already defined in Windef.h etc.)

Just in case somebody has the same problems as I had :slight_smile: