Reputation: 12363
/usr/bin/ld: cannot find -lgsl
/usr/bin/ld: cannot find -lgslcblas
collect2: ld returned 1 exit status
make[2]: *** [examples/slim_learn] Error 1
make[1]: *** [examples/CMakeFiles/slim_learn.dir/all] Error 2
make: *** [all] Error 2
I am getting a linker error while I use the make command and I think this is because the linker isn't able to find a particular GSL file even after I have set the path for LIBRARY_PATH env variable which apparently the C linker consults if unable to find a file. I am stumped as to how to fix this error. I have also set the C_INCLUDE_PATH to my gsl directory on an unrelated (most probably) note. Any help in resolving this error would be much appreciated as I am very new to linux and have no idea how to proceed.
Setting LIBRARY_PATH :
export LIBRARY_PATH=$LIBRARY_PATH:/home/PATH_TO_gls/gsl-1.16/
The make file is really long hence I am hesitant to post it here but this is the relevant part of the makefile: (please let me know if you would still like me to post the entire thing)
src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.requires:
.PHONY : src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.requires
src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides: src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.requires
$(MAKE) -f src/CMakeFiles/SLIM.dir/build.make src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides.build
.PHONY : src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides
src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o.provides.build: src/CMakeFiles/SLIM.dir/slim_fs_learn.c.o
src/CMakeFiles/SLIM.dir/slim_learn.c.o: src/CMakeFiles/SLIM.dir/flags.make
src/CMakeFiles/SLIM.dir/slim_learn.c.o: ../src/slim_learn.c
$(CMAKE_COMMAND) -E cmake_progress_report "/home/nmuralid/Desktop/Nikhil Documents/Yelp_Research/SLIM Recommender/slim-1.0/b$
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object src/CMakeFiles/SLIM.dir/slim_learn.c.o"
cd "/home/nmuralid/Desktop/Nikhil Documents/Yelp_Research/SLIM Recommender/slim-1.0/build/src" && /usr/bin/gcc $(C_DEFINES)$
Thanks in advance!
Upvotes: 1
Views: 1461
Reputation: 12363
The solution was to set LIBRARY_PATH environment variable to the paths of the libgsl.so and libgslblas.so files. This was achieved as follows:
export LIBRARY_PATH=$LIBRARY_PATH:/home/path_to_gsl/gsl-1.16/cblas/./.libs/
export LIBRARY_PATH=$LIBRARY_PATH:export LIBRARY_PATH=$LIBRARY_PATH:/home/nmuralid/path_to_gsl/gsl-1.16/.libs/
We set the LIBRARY_PATH env in this case because the C-Linker looks inside these directories in-case it fails to find the files during linking.
gls-version 1.16 used.
Upvotes: 1