Reputation: 45
g++ -o program main.cpp classOne.cpp classTwo.cpp -lgsl -lgslblas -lm
that's how i compile when the GSL-packages are installed. but now I'm working on a server where i don't have rights to install GSL-Library. What are my options?
thx
Upvotes: 2
Views: 5550
Reputation: 698
I had to do this regularly, do as following :
mypref
) and another one to build the library (let's say tmp
). You have two new directories : ~/mypref
and ~/tmp
.~/tmp
(last version is ftp://ftp.gnu.org/gnu/gsl/gsl-1.14.tar.gz), extract and go in the generated sub-directory (gsl-1.14
) :cd ~/tmp
wget ftp://ftp.gnu.org/gnu/gsl/gsl-1.14.tar.gz
tar -xvzf gsl-1.14.tar.gz
cd gsl-1.14
configure
script specifying ~/mypref
as the installation prefix (and maybe other options depending of your server) :./configure --prefix=${HOME}/mypref
make
make install
~/tmp
directory :cd; rm -rf tmp
Now you can compile your program using :
g++ -o program main.cpp classOne.cpp classTwo.cpp -I${HOME}/mypref/include -lm -L${HOME}/mypref/lib -lgsl -lgslcblas
-I
and -L
indicate respectively the path for the headers and the library. If your program is meant to be executed in a context where your home directory is not visible, consider static linking :
g++ -o program main.cpp classOne.cpp classTwo.cpp ${HOME}/mypref/lib/libgsl.a ${HOME}/mypref/lib/libgslcblas.a -I${HOME}/mypref/include -lm
The binary produced by the last command is bigger than previously, but entirely independent from GSL and GSLCBLAS.
Upvotes: 10