Results 1 to 6 of 6
I'm running Ubuntu 10.04.
I downloaded the gsl-1.15 zipped archive (current stable release )from the GNU site. I was able to extract it normally. I extracted into /usr/local/include directory, as ...
- 06-05-2011 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 30
Some issues with setting up the Gnu Scientific Library (for C)
I'm running Ubuntu 10.04.
I downloaded the gsl-1.15 zipped archive (current stable release )from the GNU site. I was able to extract it normally. I extracted into /usr/local/include directory, as a few primers mentioned this is one of a few defaults where the GCC compiler will automatically look.
Upon a standard include line in my C code, like so:
When I compile it with GCC and redirect the stderr out to a file, it gives me the following error messages:Code:#include <gsl-1.15/gsl_math.h>
Upon looking inside gsl-1.15/gsl_math.h I see it makes references to these, and the complaints seem correct in that I don't see any other reference to these missing files in the extracted files.Code:In file included from boids_1.c:3: /usr/local/include/gsl-1.15/gsl_math.h:23:25: error: gsl/gsl_sys.h: No such file or directory /usr/local/include/gsl-1.15/gsl_math.h:24:28: error: gsl/gsl_inline.h: No such file or directory /usr/local/include/gsl-1.15/gsl_math.h:25:29: error: gsl/gsl_machine.h: No such file or directory /usr/local/include/gsl-1.15/gsl_math.h:26:31: error: gsl/gsl_precision.h: No such file or directory /usr/local/include/gsl-1.15/gsl_math.h:27:25: error: gsl/gsl_nan.h: No such file or directory /usr/local/include/gsl-1.15/gsl_math.h:28:29: error: gsl/gsl_pow_int.h: No such file or directory /usr/local/include/gsl-1.15/gsl_math.h:29:28: error: gsl/gsl_minmax.h: No such file or directory
Has anyone experienced this before?
- 06-05-2011 #2Just Joined!
- Join Date
- Apr 2010
- Posts
- 30
Sorry, I need to make one correction. I looked again and these are the contents of the extracted "gsl-1.15" folder:
A number of the files that the error message complains about are actually present. Any ideas what is going on?Code:aclocal.m4 AUTHORS autogen.sh blas block bspline BUGS build.h cblas cdf ChangeLog cheb combination complex config.guess config.h.in config.sub configure configure.ac const COPYING depcomp deriv dht diff doc eigen err fft fit foldercontents.txt gsl gsl-config.in gsl-histogram.c gsl_inline.h gsl.m4 gsl_machine.h gsl_math.h gsl_minmax.h gsl_mode.h gsl_nan.h gsl.pc.in gsl_pow_int.h gsl_precision.h gsl-randist.c gsl.spec.in gsl_types.h gsl_version.h gsl_version.h.in histogram ieee-utils INSTALL install-sh integration interpolation linalg ltmain.sh Makefile.am Makefile.in matrix mdate-sh min missing mkinstalldirs monte multifit multimin multiroots multiset NEWS ntuple ode-initval ode-initval2 permutation pkgconfig.test poly qrng randist README rng roots siman sort specfunc statistics sum sys templates_off.h templates_on.h test test_gsl_histogram.sh THANKS TODO utils vector version.c wavelet
- 06-06-2011 #3Just Joined!
- Join Date
- Apr 2010
- Posts
- 30
Actually, after some messing about, I've solved it. Remember always to look inside newly extracted directories for a README or INSTALL file. This was the key to the information I needed, and likely will be for anyone who has similar confusion.
Here's what worked for me, on Ubuntu 10.04.
Download the gzipped files to /usr/local/include. Extract the folder there. It will create a folder called "gsl-xxxx" where xxxx simply denotes the version number, may or may not actually be 4 characters long.
Go into this newly created folder:
follow the instructions there. I am hesitant to give more details, as they may change with new versions, but the commands you need to run should be given to you explicitly in the INSTALL file. Upon running the "ls" command you will see that a number of files such as "config" or "libtool" are in a different colour. These are exectuables which come in the library.Code:ls /* look at contents less INSTALL /*this will let you look at the file
Using root privileges, enter the following commands within the extracted folder
After this I also had to run "make install" but I think that's because I hadn't sudo'd myself some root privileges.Code:./configure /*and wait until it's done. make /* Makefiles in the folder will do all the work, via "make", a basic util
Furthermore, the above process will create a further folder: /usr/local/include/gsl
This will store headers in a folder called simply "gsl" and so in your include statements (in your actual code you write), you will not need to use or remember the version number.
Hope this helps
- 06-06-2011 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Often software, applications, libraries, etc. are available directly through the package manager. Here's a script to demonstrate how you might do an install such as you did on ubuntu:
producing:Code:#!/usr/bin/env bash # @(#) s1 Demonstrate apt-cache, apt-get for search, install. # Utility functions: print-as-echo, print-line-with-visual-space, debug. pe() { for _i;do printf "%s" "$_i";done; printf "\n"; } pl() { pe;pe "-----" ;pe "$*"; } db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; } db() { : ; } C=$HOME/bin/context && [ -f $C ] && $C pl " Search for gsl items, partial listing:" apt-cache search gsl | head -10 pl " Look at the library offering, partial listing:" apt-cache show libgsl0ldbl | head -10 pl " See status of libgsl0ldbl:" apt-cache policy libgsl0ldbl pl " Do test install -- remove \"-s\" (simulate) for real install:" # sudo apt-get -s install libgsl0ldbl exit 0
Normally one would do that interactively. You may have needed a more recent version of GSL, but if the version currently available is good enough, then the package manager seems better for a number of reasons -- not the least of which is that one's system is consistently managed. Another is that system security updates can be easily installed. However, package management is a topic too large and complex to do it justice in a post like this, other than to make one aware of the possibilities.Code:% ./s1 Environment: LC_ALL = C, LANG = C (Versions displayed with local utility "version") OS, ker|rel, machine: Linux, 2.6.32-32-generic, i686 Distribution : Ubuntu 10.04.2 LTS (lucid) GNU bash 4.1.5 ----- Search for gsl items, partial listing: libgsl0-dbg - GNU Scientific Library (GSL) -- debug symbols package libgsl0-dev - GNU Scientific Library (GSL) -- development package libgsl0ldbl - GNU Scientific Library (GSL) -- library package gsl-bin - GNU Scientific Library (GSL) -- binary package gsl-ref-html - GNU Scientific Library (GSL) Reference Manual in html gsl-ref-psdoc - GNU Scientific Library (GSL) Reference Manual in postscript libgsl-ruby - Ruby bindings for the GNU Scientific Library (GSL) (dummy package) libgsl-ruby-doc - Documentation for Ruby/GSL (libgsl-ruby) libgsl-ruby1.8 - Ruby bindings for the GNU Scientific Library (GSL) libocamlgsl-ocaml - GNU scientific library for OCaml ----- Look at the library offering, partial listing: Package: libgsl0ldbl Priority: optional Section: math Installed-Size: 2260 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Dirk Eddelbuettel <edd@debian.org> Architecture: i386 Source: gsl Version: 1.13+dfsg-1 Replaces: gsl, libgsl0 (<= 1.9-4) ----- See status of libgsl0ldbl: libgsl0ldbl: Installed: 1.13+dfsg-1 Candidate: 1.13+dfsg-1 Version table: *** 1.13+dfsg-1 0 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages 100 /var/lib/dpkg/status ----- Do test install -- remove "-s" (simulate) for real install:
Note that there are several interfaces to the package manager, APT in Debian and Ubuntu. I use apt-get, and apt-cache for queries, others like aptitude, etc. ( There are similar -- but different -- facilities in RedHat, SuSE, FreeBSD, etc.)
Googling for tutorials, and reading the (long) man pages for apt-get, apt-cache, may be useful, along with some practice, such as installing something easy, say tree:
Best wishes ... cheers, drlCode:apt-cache show tree ... Description: displays directory tree, in color directory tree, in color ...
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 06-06-2011 #5Just Joined!
- Join Date
- Apr 2010
- Posts
- 30
Thanks for the heads up, I had wanted to do the install myself, because I don't know much about where/how programs like Synaptic deal with packages. I have now also tried using Synaptic to install the GSL development package, which has worked with one caveat (below). This problem came up with my method, and with Synaptic or apt-get installs, so I think it may be a quirk of GSL.
I have a follow up / troubleshooting question for anyone who may be able to help.
I am trying a simple vector script to try to get the hang of GSL, given below:
Upon compilation, the gcc compiler complains that it doesn't recognize the any of the gsl_vector functions I've called (gsl_vector_alloc, gsl_vector_set, gsl_vector_get, gsl_vector_free) . However, if I just declare the vector it seems to have no problem.Code:#include <stdio.h> #include <gsl/gsl_math.h> #include <gsl/gsl_vector.h> int main () { int i; gsl_vector * v = gsl_vector_alloc (3); for (i = 0; i < 3; i++) { gsl_vector_set (v, i, 1.23 + i); } for (i = 0; i < 100; i++) /* OUT OF RANGE ERROR */ { printf ("v_%d = %g\n", i, gsl_vector_get (v, i)); } gsl_vector_free (v); return 0; }
I've been able to use <gsl_math.h> without further issue, accessing member functions and constants. Does anyone know what might be missing package wise?
- 06-06-2011 #6Just Joined!
- Join Date
- Apr 2010
- Posts
- 30
Okay, to continue this trend of me answering my own questions, (perhaps badly), I was able to get the above C code to work, but I had to add some flags to the gcc call.
gcc -o vectors.x vectors.c -lgsl -lgslcblas
Again, I'm no expert in Linux or on how compilers work, so I leave it to the gurus here to maybe comment on exactly what's going on but here's what I can surmise:
Upon looking at the documentation page for GSL GSL - GNU Scientific Library - GNU Project - Free Software Foundation (FSF) (under the heading "Related Packages"), it reads:
" GSL requires a BLAS library for vector and matrix operations. The default CBLAS library supplied with GSL can be replaced by the tuned ATLAS library for better performance ..."
I looked inside /usr/local/bin and ran the command:
Doing this will bring up some options, printed below:Code:./gsl-configure
I then ran the above command using the --libs flag and got the following output:Code:Usage: gsl-config [OPTION] Known values for OPTION are: --prefix show GSL installation prefix --libs print library linking information, with cblas --libs-without-cblas print library linking information, without cblas --cflags print pre-processor and compiler flags --help display this help and exit --version output version information An external CBLAS library can be specified using the GSL_CBLAS_LIB environment variable. The GSL CBLAS library is used by default.
so as far as I can tell, adding "-lgsl" and "-lgslcblas" to the GCC call is necessary to link to the CBLAS routines upon which GSL depends.Code:-L/usr/local/lib -lgsl -lgslcblas -lm
If I've misrepresented or misunderstood anything, I welcome criticism, it would help me out to better understand, and likely for anyone who is having similar issues.


Reply With Quote