UE4_LINUX_USE_LIBCXX=0 Fails to Compile

I pulled the latest Unreal Engine a few days ago and I was able to build and run it just fine by following the quickstart guide. I have some external libraries compiled with my system’s GCC and linked to my system’s libstdc++ that I would like to use as external modules. I immediately ran into C++ ABI problems of course because I linked with libstdc++ while Unreal is using it’s own toolchain’s libc++. I would like to recompile Unreal Engine to link against my system’s libstdc++. I understand the ramifications of this and I know whatever I build will only work with my system and that’s expected and fine.

My system is Ubuntu 18 with gcc 7.5.0:

gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Output of uname -a

uname -a
Linux <...> 5.4.0-65-generic #73~18.04.1-Ubuntu SMP Tue Jan 19 09:02:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

The build errors imply the wrong stdlib headers are being found, or the stdlib headers aren’t even being found, or somehow they are found but -std=c++14 isn’t being passed. I’ve at least confirmed -std=c++14 is being passed.

Build errors:

------- Build details --------
Using toolchain located at '.../workspace/unreal/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu'.
Using clang (.../workspace/unreal/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++) version '10.0.1' (string), 10 (major), 0 (minor), 1 (patch)
Using compiler default (most likely libstdc++) standard C++ library.
Using lld linker
Using llvm-ar : .../workspace/unreal/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin/llvm-ar
Using fast way to relink  circularly dependent libraries (no FixDeps).
------------------------------
Performing 38 actions (12 in parallel)
[5/38] Compile SharedPCH.Core.ShadowErrors.h
[2/38] Compile PCH.CoreUObject.h
[3/38] Compile Module.TraceLog.cpp
[4/38] Compile BuildSettings.cpp
[6/38] Compile Module.UnrealHeaderTool.cpp
[1/38] Compile PCH.Core.h
[7/38] Link (lld) libUnrealHeaderTool-BuildSettings.so
In file included from .../workspace/unreal/Engine/Intermediate/Build/Linux/B4D820EA/UnrealHeaderTool/Development/Core/SharedPCH.Core.ShadowErrors.h:59:
In file included from .../workspace/unreal/Engine/Source/Runtime/Core/Public/CoreSharedPCH.h:65:
In file included from Runtime/Core/Public/Containers/Map.h:14:
.../workspace/unreal/Engine/Source/Runtime/Core/Public/Templates/Tuple.h:66:89: error: no member named 'is_same' in namespace 'std'
                constexpr static uint32 Value = TTypeCountInParameterPack<T, Types...>::Value + (std::is_same<T, U>::value ? 1 : 0);
                                                                                                 ~~~~~^
.../workspace/unreal/Engine/Source/Runtime/Core/Public/Templates/Tuple.h:66:97: error: 'T' does not refer to a value
                constexpr static uint32 Value = TTypeCountInParameterPack<T, Types...>::Value + (std::is_same<T, U>::value ? 1 : 0);

Hi,

Compiling with UE4_LINUX_USE_LIBCXX=0 is neither tested nor supported. It worked out of the box at some point, but there had been since changes that are not compatible with the switch and certain bundled third party libs would need to be recompiled to support it. The switch is intended to provide a starting point for the advanced users who want to revert to using libstdc++ (note that distributing your project binaries may now be more complicated, if you ever decide so), but they are expected to work out the compilation and linking issues themselves, as maintaining two copies of the same bundled libraries compiled for two different STLs is not deemed practical at this point.

Hope this helps and sorry to not have a better answer for you.

-RCL

Thank you for the quick response! I realize that by doing this I’m losing multi-linux compatibility that Unreal’s build system is aiming for but in my case that’s perfectly fine right now.

I was able to force the compile to begin with a system-installed version of clang that I could point to my system’s libstdc++ with some tweaks to LinuxToolChain.cs and make ARGS=“-ForceUseSystemCompiler”. I ran into another issue when linking what was being built with the third party libraries though. Unreal’s Setup.sh downloads pre-compiled third-party binaries that are linked against Unreal-clang’s libc++. I’d like to recompile Unreal’s ThirdParty dependencies but when I run BuildThirdParty.sh it fails at LibZ with a mysterious error about x86_64-unknown-linux-gnu.

I have no yet dove into why this error is happening but I think BuildThirdParty.sh is no longer tested and working as well. Is there a suggestion for how I can compile the third party libs on my own cleanly without downloading pre-compiled libs? For context I’m evaluating Unreal as a product to integrate with a large legacy code base of Ubuntu18 libraries and source all of which are compiled and linked against libstdc++.

Error below:

building zlib
+ cd Source/ThirdParty/zlib/zlib-1.2.5/build
...
+ make -j4
/usr/bin/cc -fPIC -D_LARGEFILE64_SOURCE=1  x86_64-unknown-linux-gnu -c -o example.o example.c
/usr/bin/cc -fPIC -D_LARGEFILE64_SOURCE=1  x86_64-unknown-linux-gnu -c -o adler32.o adler32.c
/usr/bin/cc -fPIC -D_LARGEFILE64_SOURCE=1  x86_64-unknown-linux-gnu -c -o compress.o compress.c
/usr/bin/cc -fPIC -D_LARGEFILE64_SOURCE=1  x86_64-unknown-linux-gnu -c -o crc32.o crc32.c
clangclangclang: : : error: errorno such file or directory: 'x86_64-unknown-linux-gnu': clang
no such file or directory: 'x86_64-unknown-linux-gnu': 
error: no such file or directory: 'x86_64-unknown-linux-gnu'
error: no such file or directory: 'x86_64-unknown-linux-gnu'