[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] unable to compile program with gsl in a MAC OS X
From: |
Steven Vancoillie |
Subject: |
Re: [Help-gsl] unable to compile program with gsl in a MAC OS X |
Date: |
Fri, 17 Oct 2008 21:20:32 +0200 |
User-agent: |
KMail/1.9.9 |
On Friday 17 October 2008 20:59:16 Luis Borda de Agua wrote:
>
> I installed gsl using mac ports. unfortunately when I tried to run one
> of your examples, it didn't work. Here are the details:
>
> - gsl version 1.11
>
> - Mac OS X 10.5.5 (Leopard); processor 2.5 GHz intel Core 2 Duo
>
> - gcc (lrwxr-xr-x 1 root wheel 7 Mar 14 2008 gcc ->
> gcc-4.0)
>
> This was the program I used (one of your examples):
>
> #include <stdio.h>
> #include <gsl/gsl_sf_bessel.h>
>
> int
> main (void)
> {
> double x = 5.0;
> double y = gsl_sf_bessel_J0 (x);
> printf ("J0(%g) = %.18e\n", x, y);
> return 0;
> }
>
> - This is how I try to compile it
>
> $ gcc -Wall -I/usr/local/include asd.c
>
> ("asd.c" being the name of file with the code)
>
> - This was the error message:
>
> Undefined symbols:
> "_gsl_sf_bessel_J0", referenced from:
> _main in ccnvBbbv.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
> __________
>
> I realize that mac ports in fact installed the gsd in the directory /
> opt/local/include
> so I also tried
>
> $ gcc -Wall -I/opt/local/include asd.c
>
> but I got exactly the same error message. I then moved the gsl library
> to /usr/local/include
> and I got the error message described above.
>
> I would appreciate if someone could help me with this.
> Yours,
>
> Luís Borda de Água
> Dept. of Ecology and Evolutionary Biology
> 621 Charles E. Young Drive
> University of California
> LOS ANGELES CA 90095
> Phone: +1 (310) 206 2801
> Fax: +1 (310) 206 3907
> ____________________________________
> Luís Borda de Água
> Dept. of Ecology and Evolutionary Biology
> 621 Charles E. Young Drive
> University of California
> LOS ANGELES CA 90095
> Phone: +1 (310) 206 2801
> Fax: +1 (310) 206 3907
>
>
>
>
>
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>
I don't know what linker is used on the mac os, but for GNU/Linux using the GNU
linker ld
you need to link with the gsl library like this:
gcc -Wall asd.c -lgsl -lgslcblas (or your own cblas library)
this should work when gsl libraries are in a standard directory like /usr/lib
or /usr/local/lib
if not, you can specify any additional directories to look in with the -L
option.
e.g. if gsl would be in /home/user/mylib:
gcc -Wall asd.c -L/home/user/mylib -lgsl -lgslcblas
grtz
Steven