Reputation: 313
I am installing clang from source using CMake. I have a gcc 4.9.2 installation in a non-system path e.g. /gcc/path/.
I use the recommended:
CC=... CXX=... cmake -DCMAKE_GCC_INSTALL_DIR=... -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath,/gcc/path/lib64"
This compiles my sample code fine and when I
readelf -d clang++ | grep RPATH
it correctly outputs my specified rpath. However, the compiled object file doesn't contain any RPATH and gives me the error:
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
I know the above error occurs because the library search path is not specified correctly. But I want to avoid setting LD_LIBRARY_PATH and wanted to pass the correct linker flags through cmake.
Interestingely when I compile using the following:
clang++ sample.cpp -std=c++11 -Wl,-rpath,/gcc/path/lib64
the executable does contain the correct rpath. I dont want to specify this compiler flag explicitly though and want the object file to use the rpath that the compiler was configured with. Is that possible through a cmake build? If so how?
Upvotes: 3
Views: 4960