I'm trying to compile my program with custom gcc, after cmake generated makefiles. I've done following:
CMAKE_CXX_COMPILER
to path to custom built, let's say /home/user/pkgs/bin/g++
.However, when I'm trying to run program it shows erros like:
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.21' not found
It seems to me, that problem is in linking to old libraries in /usr/lib
, whereas linking should be done to cutom gcc libraries.
How can I fix this?
Just do TARGET_LINK_LIBRARIES(program /path/to/library.so) > > > > 2. Better one is to: > > > > FIND_LIBRARY(MY_LIB NAMES library > > PATHS /path/to) > > TARGET_LINK_LIBRARIES(program ${MY_LIB}) > > > > Andy > > > > On Fri, 2004-10-29 at 10:19, Ning Cao wrote: > >> I want to link a .
target_link_libraries is probably the most useful and confusing command in CMake. It takes a target ( another ) and adds a dependency if a target is given. If no target of that name ( one ) exists, then it adds a link to a library called one on your path (hence the name of the command).
Usually under Linux, one uses CMake to generate a GNU make file which then uses gcc or g++ to compile the source file and to create the executable. A CMake project is composed of source files and of one or several CMakeLists.
The problem is not specific to CMake. You have it with all custom installs of GCC, that ship a new version of libstdc++.
You can either change your LD_LIBRARY_PATH to point to your gcc install path
export "LD_LIBRARY_PATH=/home/user/pkgs/lib:$LD_LIBRARY_PATH"
or you could link statically to libstdc++.so.6 by adding -static-libstdc++
to your CMAKE_CXX_FLAGS or you could change the rpath of your target to include /home/user/pkgs/lib
(see cmake wiki on rpath)
, however this only works if you run the program only on the machine it was compiled on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With