Installing a library

Discuss Programming
Post Reply
TheQuirk
programmer
programmer
Posts: 114
Joined: Wed Jan 22, 2003 4:11 pm

Installing a library

Post by TheQuirk » Mon Jul 13, 2009 4:01 pm

I am trying to use the GNU scientific library (http://www.gnu.org/software/gsl/), but I don't have root access, so I did this:

Code: Select all

$ ./configure --prefix=$HOME/gsl
$ make
$ make install
everything compiled fine, but now I am not sure how to use the library!

I've tried using the -L and -I options with gcc, but I am not getting anywhere. What is the right way to do this?

I know that I should know this by now, but, well, I don't.

edit: it seems like my user ranking (or whatever you call it) is wrong. :)

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Mon Jul 13, 2009 5:57 pm

In your ~/gsl/bin you should find a script that will print out the options you need:

Code: Select all

$ ~/gsl/bin/gsl-config --libs --cflags

TheQuirk
programmer
programmer
Posts: 114
Joined: Wed Jan 22, 2003 4:11 pm

Post by TheQuirk » Tue Jul 14, 2009 7:56 am

Thanks for the help!

I am still having some problems making it know where the shared library is.

This is what I have:

Code: Select all

glebzh@vminteractive:~/gsl_test$ ~/gsl/bin/gsl-config --libs --cflags -L/home/users/glebzh/gsl/lib -lgsl -lgslcblas -lm -I/home/users/glebzh/gsl/include
glebzh@vminteractive:~/gsl_test$ gcc test.c -L/home/users/glebzh/gsl/lib -lgsl -lgslcblas -lm -I/home/users/glebzh/gsl/include
glebzh@vminteractive:~/gsl_test$ ./a.out
./a.out: error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory
I tried looking up something things online (e.g. http://www.linux.org/docs/ldp/howto/Pro ... aries.html), but I can't seem to do it right.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Tue Jul 14, 2009 8:19 am

Oh, it's a shared library. You'll need to make sure when you run the program that your library directory is in your library path. Normally that is done by putting the directory in /etc/ld.so.conf (or a conf file in /etc/ld.so.conf.d) and running ldconfig but you don't have root access so you'll have to make sure the directory containing the shared library you want to use is in your LD_LIBRARY_PATH environment variable before you run the program:

export LD_LIBRARY_PATH=/home/users/glebzh/gsl/lib:$LD_LIBRARY_PATH

TheQuirk
programmer
programmer
Posts: 114
Joined: Wed Jan 22, 2003 4:11 pm

Post by TheQuirk » Tue Jul 14, 2009 8:39 am

Great! It worked, thanks.

Post Reply