linking external libraries
Posted: Thu Aug 11, 2016 6:26 pm
I am using some functionality from the gsl library, which I have installed using homebrew into /usr/local/Cellar/gsl/1.16/ and macports into /opt/local/lib
When I compile my code, I get a linking error
so it seems that the compiler cannot link the library. Can I set this somehow in the CMakeLists?
In the CMakeLists.txt of my project, I tried:
but that did not help.
Another weird thing is that after running cmake, the file build/CMakeCache.txt has:
there is a library for gsl in that location, yet the compiling doesn't work. Would anyone be able to help? I am on Mac OS El captain, using gcc version 7.3.0
When I compile my code, I get a linking error
Code: Select all
[ 13%] Linking CXX shared library libbaseRobot.dylib
Undefined symbols for architecture x86_64:
"_gsl_ran_levy", referenced from:
BaseRobot::DoLevyWalk() in baseRobot.cpp.o
"_gsl_rng_alloc", referenced from:
BaseRobot::Init(ticpp::Element&) in baseRobot.cpp.o
"_gsl_rng_default", referenced from:
BaseRobot::Init(ticpp::Element&) in baseRobot.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [controllers/libbaseRobot.dylib] Error 1
make[1]: *** [controllers/CMakeFiles/baseRobot.dir/all] Error 2
make: *** [all] Error 2
In the CMakeLists.txt of my project, I tried:
Code: Select all
# Set ARGoS link dir
link_directories(${ARGOS_LIBRARY_DIRS} /usr/local/Cellar/gsl/1.16/lib/)
Another weird thing is that after running cmake, the file build/CMakeCache.txt has:
Code: Select all
CMAKE_EXE_LINKER_FLAGS:STRING= -L/opt/local/lib