[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] GSL Installation problem

From: Marco Maggi
Subject: Re: [Help-gsl] GSL Installation problem
Date: Fri, 02 Oct 2009 09:40:56 +0200

"syed raza" wrote:
> I want to compile a program of simple Matrix using gcc and
> GSL.

Ciao,  in what  follows I  assume  you are  a beginner  with
GNU+Linux platforms,  so bear with  it if I write  stuff you
already know.   There are a lot  of things to say  and it is
difficult to have this exchange through email; anyway, let's
give it a try.

  If you do a Google  search for "how to compile and install
a program under linux", you  will find a number of tutorials
about how  to compile and  install programs; I  suggest that
you read some of them.

  Now for the specific  task of compiling and installing the
GSL: first,  you should unpack  the archive "gsl-1.9.tar.gz"
in a  temporary directory.

  On  my  system,  my  user  name is  "marco",  so  my  home
directory pathname  is "/home/marco"; in  everything below I
use this  pathname, you should  use your own  home directory
pathname.   When  I build  a  GSL package  I  do  it in  the
temporary  directory "/home/marco/var/build".  It  goes like
this,  assuming  that   "gsl-1.9.tar.gz"  is  a  file  under

  $ cd /home/marco
  $ mkdir -p var/build
  $ cd var/build
  $ tar --extract --gzip --verbose --file=/home/marco/gsl-1.9.tar.gz
  $ cd gsl-1.9
  $ ./configure --disable-static --enable-shared
  $ make

if everything works  the GSL is configured and  built by the
last two commands; we can verify that the building worked by
running the tests:

  $ make check

you should see a lot of compiler invocations and messages

1 test passed

meaning  that  a  test  program  was  run  and  successfully
executed.  Running the tests may take some minute.

  Now we have to install  the GSL; we configured it with the
default setting for the destination directory, so it will be
installed under the "/usr/local" directory hierarchy.

  First, you  have to  make sure that  "/usr/local" is  in a
hard   disk   partition   mounted   with   writable   access
permissions.   For   example,  on  my   system  running  the
following command:

  $ mount | grep /usr/local


/dev/sda11 on /usr/local type ext3 (rw,nodev,errors=remount-ro)

the first "rw" in the parentheses shows that "/usr/local" is
writable.   There is  too much  to  be told  about how  your
system  may  be  configured;  so,  let's  assume  that  your
"/usr/local" is  writable, and come  back to it only  if the
installation fails.

  To install GSL you  need to acquire root permissions, this
means use the "su"  program or "sudo" program.  "sudo" needs
to be configured, while "su"  should work for you; let's use
"su".  If you do a Google search on "how to use su on linux"
you should find some tutorials on it.

  Basically to install GSL you should do:

  $ su
  $ make install
  $ /sbin/ldconfig
  $ exit

the "su" program asks you to type in the "root" password; do
it and  "su" will run  a shell under "root"  privileges; run
"make  install" and  "ldconfig" and  finally type  "exit" to
exit the privileged shell.

  The location of "ldconfig"  may vary on your Linux system,
I do not know where Mandriva places it; it may be in one of
the following locations:


or  some  other place.   Find  it  and  run it  with  "root"

  Now, on to compiling a  program linked to the GSL library.
The  source file  of your  program is  called "matrixExp.c",
fine; first put it under a temporary directory:

  $ cd <where the file is>
  $ mkdir /home/marco/var/tmp
  $ mv matrixExp.c /home/marco/var/tmp
  $ cd /home/marco/var/tmp

  Your program looks fine to me, meaning that I successfully
compiled and  run it on  my system with the  commands below.
When  linking to  the  GSL  library, you  have  to tell  the
compiler how  to use it;  the GSL package installs  a script
"gsl-config" which we can use to acquire the informations we
need.  You can try to run this:

  $ gsl-config --cflags --libs

on my system it prints:

-L/usr/local/lib -lgsl -lgslcblas -lm

these are all options to be put on the command line of GCC;
so let's try:

  $ gcc -I/usr/local/include -L/usr/local/lib -lgsl -lgslcblas -lm -o matrixExp 

it should compile the program and create an executable named
"matrixExp"; equivalently, using the features of the shell
you are running you could do:

  $ gcc $(gsl-config --cflags --libs) -o matrixExp matrixExp.c

  To run the program:

  $ ./matrixExp

which prints:

differences = 0 (should be zero)

  I hope  all of this helps  you; to have  further help, you
can reply to me by private email.
Marco Maggi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]