Building Linux lib using Native Toolchain and CMake

Hi all, I’m trying to build a Linux lib (in this case - librdkafka) using Unreal’s native Linux toolchain (Native Toolchain | Unreal Engine Documentation) for later usage in the Unreal Linux server plugin. In CMake, I’m setting the CMAKE_C_COMPILER as “v12_clang-6.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang”, and CMAKE_CXX_COMPILER as “v12_clang-6.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++”, but, after configure the following errors appears:

    Building C object CMakeFiles/cmTC_4d8ce.dir/testCCompiler.c.o
    /home/shiny/Dokumenty/v12_clang-6.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang    -MD -MT CMakeFiles/cmTC_4d8ce.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_4d8ce.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_4d8ce.dir/testCCompiler.c.o -c /home/shiny/Dokumenty/librdkafka-1.6.2/out/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_4d8ce
    /snap/cmake/1000/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4d8ce.dir/link.txt --verbose=1
    /home/shiny/Dokumenty/v12_clang-6.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang -rdynamic CMakeFiles/cmTC_4d8ce.dir/testCCompiler.c.o -o cmTC_4d8ce 
    /home/shiny/Dokumenty/v12_clang-6.0.1-centos7/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o: unrecognized relocation (0x2a) in section `.text'
    /home/shiny/Dokumenty/v12_clang-6.0.1-centos7/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ld: final link failed: Bad value
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

Can anybody tell me how to adjust other CMake settings to successfully generate make files? Is it even possible to generate makefiles using this toolchain and CMake? Are there other ways to build this lib on Linux using this toolchain?

This package links to ZLib, cURL, ZSTD and SSL.
CMake searches for these packages, installed in the OS and links to them.

UE4 has their own versions of ZLib and cURL (at least these two, maybe, other are included too), which cause conflicts and errors.

You need either to turn them off, or specify paths to UE4 versions for CMake

Following command run on my PC did not produce errors:

cmake .. -DCMAKE_CXX_COMPILER=/home/wl2776/work/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++ -DWITH_CU

More details are here: Introduction to conan-ue4cli | Adam Rehn Docs