2

I'm trying to to build a project (https://github.com/UWQuickstep/quickstep) which seems to use cmake, against newly compiled glibc installed in a different location (https://sourceware.org/glibc/wiki/Testing/Builds#Compile_against_glibc_in_an_installed_location). The project builds quickstep_cli_shell executable as the only target.

I would like to build the project with the following compile options added to the build (where SYSROOT=<new glibc installation dir>)

  -L${SYSROOT}/usr/lib64 \
  -I${SYSROOT}/include \
  --sysroot=${SYSROOT} \
  -Wl,-rpath=${SYSROOT}/lib64 \
  -Wl,--dynamic-linker=${SYSROOT}/lib64/ld-2.18.90.so\
  1. I added the following lines at the top of the cmake file (https://github.com/UWQuickstep/quickstep/blob/master/CMakeLists.txt)
set(CMAKE_VERBOSE_MAKEFILE on)
set(SYSROOT /fastdisk/glibc-master-install)
add_compile_options("-L${SYSROOT}/usr/lib64" "--sysroot=${SYSROOT}" "-Wl,-rpath=${SYSROOT}/lib64" "-Wl,--dynamic-linker=${SYSROOT}/lib64/ld-2.30.so")
include_directories(BEFORE "${SYSROOT}/include")
  1. When I run cmake .. && make from the build directory, I see that all object files are built with proper compile options, except for the final executable.

Any other object file -

/usr/bin/c++ -I/fastdisk/glibc-master-install/include <some other includes> -std=c++14 <some other options> -L/fastdisk/glibc-master-install/usr/lib64 --sysroot=/fastdisk/glibc-master-install -Wl,-rpath=/fastdisk/glibc-master-install/lib64 -Wl,--dynamic-linker=/fastdisk/glibc-master-install/lib64/ld-2.30.so -o CMakeFiles/quickstep_utility_Macros.dir/__/empty_src.cpp.o -c /fastdisk/quickstep/empty_src.cpp

Final quickstep_cli_shell build

/usr/bin/c++   -std=c++14 <some other options> -rdynamic CMakeFiles/quickstep_cli_shell.dir/cli/QuickstepCli.cpp.o  -o quickstep_cli_shell <all .a dependencies>
$ quickstep/build# ldd quickstep_cli_shell 
    linux-vdso.so.1 (0x00007ffc5ff6f000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f09b6d50000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f09b69c7000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f09b6629000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f09b6411000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f09b6020000)  ------> should point to libc in $SYSROOT
    /lib64/ld-linux-x86-64.so.2 (0x00007f09c50a1000)

I have spent lots of hours trying to figure out a way to build the final target executable by linking it against the new glibc but haven't found any success yet (I use cmake 3.10.2, if it helps).

Is there something wrong with my cmake changes? How do I build the target properly?

nsane
  • 1,715
  • 4
  • 21
  • 31
  • 2
    `-L`, `-Wl` are definitely NOT a compile options, so adding them with `add_compile_options` is wrong. Try to set `CMAKE_EXE_LINKER_FLAGS` instead. "I added the following lines at the top of the cmake file" - Instead, you may create a toolchain file, which can be given to `cmake` itself without modifying the project's `CMakeLists.txt`. – Tsyvarev Nov 16 '19 at 21:16
  • Thank you! Setting `CMAKE_EXE_LINKER_FLAGS` worked. – nsane Nov 16 '19 at 22:22
  • It is a pity this good question (in my opinion, and also because the upvotes to it). The also good answer by @Tsyvarev was a comment instead of an answer, so the the OP coult not accept the answer. Because that, future SO readers are less likely going to find this useful information. – Former contributor Nov 18 '19 at 10:19
  • @Pedro: Well, I have marked the question as a duplicate for one about setting linker and compiler flags. – Tsyvarev Nov 18 '19 at 10:56
  • @Tsyvarev: Yes, for the quick and dirty accepted solution. I would upvote instead your suggestion for a new toolchain file without needing to modify the original CMakeLists.txt – Former contributor Nov 18 '19 at 11:16

0 Answers0