Notes on using gnu Scientific Library on Athena by alexp (Alex Prengel) 3/12/07 The gnu Scientific Library 1.9 has been installed on Athena for Sun and Linux. All libraries and binaries were built from source; default Athena 9.4 gcc compilers were used (Sun: gcc version 3.4.3, Linux: gcc version 3.4.6 20060404. Both static and dynamic libraries have been built; however fully static binaries are generally not possible as libc and libX11, needed by most applications, are not available in static form on all platforms. You will need to add the gnusl locker. Sourcing the file /mit/gnusl/cshrc after this will set proper paths and environment variables for building your applications; setting the GSL_VERSION environment variable to 1.9 before sourcing cshrc will ensure that the new 1.9 release is used. The gsl-config utility, located in the gnusl_v1.9 locker (and accessible from the gnusl locker) can be used to determine compiler and linker flags suitable for building your applications- see the gsl-config man page for details. You will need to use include files in /mit/gnusl_v1.9/include in your applications, i.e. like: #include (or whatever other includes your application requires) and link against libraries in /mit/gnusl_v1.9/lib; generally you will need to use libgsl and libgslblas and the system math library. To do this you normally should have the following on your command line: -I/mit/gnusl_v1.9/include -L/mit/gnusl_v1.9/lib -lgsl -lgslcblas -lm Note that you can use gsl-config output to generate this, i.e. gcc -O2 -o myfile `gsl-config --libs --cflags` myfile.c When you run dynamically linked binaries you build with GSL later, you will need to point the runtime system to the dynamic libraries through the LD_LIBRARY_PATH environment variable. This is done automatically if you add the gnusl locker and source /mit/gnusl/cshrc (setting GSL_VERSION if you are not using the default version), but you probably won't want to do this every time you run something. A fairly simple way around this is to rename your binary and use a small "wrapper" script. If your binary is "foo", rename it to "foo.real", and write a shell script called "foo" as follows: #!/bin/sh this=`dirname $0` gnusl_default=gnusl_v1.9 if test -s /etc/athena/reactivate then isathena=1 attach -q gnusl else isathena=0 ATHENA_SYS=${ATHENA_SYS-`fs sysname | awk '{ print substr($4,2,length($4)-2)}'`}export ATHENA_SYS attach gnusl >/dev/null fi if test "${GSL_VERSION-undefined}" = "undefined" then GSL_LOCKER=gnusl_default else GSL_LOCKER=gnusl_v${GSL_VERSION} fi if test "${LD_LIBRARY_PATH-undefined}" = "undefined" then LD_LIBRARY_PATH="/mit/gnusl/${GSL_LOCKER}/lib:$LD_LIBRARY_PATH" else LD_LIBRARY_PATH="/mit/gnusl/${GSL_LOCKER}/lib" fi export LD_LIBRARY_PATH exec ${this}/foo.real "$@" PLEASE NOTE THAT WE CAN'T GUARANTEE THAT DYNAMIC LIBRARIES WILL STAY AROUND INDEFINITELY IN THE SAME LOCATIONS THEY ARE IN NOW! THIS MAY BREAK DYNAMICALLY LINKED BINARIES! You may want to copy the relevant dynamic libraries to a location of your choosing, or use static linking instead. Note that the current default version of the library will be used, but this may be overridden by setting the GSL_VERSION environment variable at run time. Note that the script above will use the "default" version of the library- if you require a specific version (like 1.9), you can replace the gnusl above by a version-specific form, i.e. gnusl_v1.9. There is much documentation available- man pages and gnu info docs in the locker, and various READMEs in the top level directory. Online documentation is at http://www.gnu.org/software/gsl/manual/html_node/ To view the info format docs: add gnusl_v1.9 gnu setenv INFOPATH /mit/gnusl_v1.9/info info gsl-ref man pages for gsl-config, gsl-histogram and gsl-randist are in the gnusl_v1.9 locker.