GSL (http://www.gnu.org/software/gsl/) is a great C/C++ library for scientific computing. I always install a current copy of GSL in the server that I use. However, I don’t have admin access on those servers, and, as a result, I cannot use ldconfig to add gsl library. The following trick help me to compile my gsl C++ code.
1). Define environment variable $LD_LIBRARY_PATH (in BASH);
, where $HOME/ext/lib is where gsl library are installed and contains “libgsl.so.0” and other files.
2). Compile the C++ code and link them to gsl.
g++ gen_data.cpp -o gen_data -I/home/biobeatext/include -L /home/biobeat/ext/lib -lgsl -lgslcblas
3). Now ./gen_data will execute the code.
Without defining $LD_LIBRARY_PATH in Step 1, the following error message will be displayed when executing gen_data:
./gen_data: error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory
This is because the shell cannot find libgsl.so.0 in ldconfig path, which can only be set by admin.