Last active
April 30, 2019 06:10
-
-
Save RCL/6e2491729977dc9ba55967edc988b0bc to your computer and use it in GitHub Desktop.
Options to compile against UE4's libc++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Compile: | |
| -nostdinc++ -I $UE_THIRD_PARTY_DIR/Linux/LibCxx/include/ -I $UE_THIRD_PARTY_DIR/Linux/LibCxx/include/c++/v1 | |
| Link: | |
| -nodefaultlibs -L $UE_THIRD_PARTY_DIR/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/ $UE_THIRD_PARTY_DIR/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/libc++.a $UE_THIRD_PARTY_DIR/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/libc++abi.a -lm -lc -lgcc_s -lgcc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recently dug into this, and found that
-nodefaultlibstogether with-lc -lm -lgcc_s -lgcclinker flags are not necessary and should not present, while-stdlib=libc++is necessary.So, the full flags should look something like:
CXX_FLAGS="-stdlib=libc++ -std=c++11 -nostdinc++ -I $UE_THIRD_PARTY_DIR/Linux/LibCxx/include/ -I $UE_THIRD_PARTY_DIR/Linux/LibCxx/include/c++/v1"LD_FLAGS="-L$UE_THIRD_PARTY_DIR/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu/ -lc++ -lc++abi"Furthermore, when using CMAKE, especially when building
grpcwithgoogle/benchmark, the C++ feature testing usesclang++alone to perform both compiling and linking (of course, internally,clang++invokesldfor linking), so one has to pass the linker flags throughclang++- otherwise, the feature testing code snippets, such asstd_regex.cpp, won't link correctly, and thus preventing subsequent building, so correct flags for buildinggrpcagainst UE4's staticlibc++/abi.ashould look like:CLANG_FLAGS_WITH_CMAKE_FEATURE_TESTING="${CXX_FLAGS} ${LD_FLAGS}"Finally,
lddis a useful tool to check shared library dependencies of an executable - runldd <binary>, and it should not contain a dependency tolibc++.so.1, because the flags above should link your binary statically against UE4's staticlibc++/abi.alibs - otherwise, if there does contain a dependency tolibc++.so.1, then something must not be working correctly!