help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] an error while compiling c++ using GSL


From: Mohammad Akhlaghi
Subject: Re: [Help-gsl] an error while compiling c++ using GSL
Date: Mon, 1 Jan 2018 17:01:10 +0100
User-agent: K-9 Mail for Android

Dear MohammadAmin,

You need to tell your C++ compiker (g++) to link with the GSL library and then 
the C math library. 

You can do this with the compiler's `-l' (link) option in a command like this:

$ g++ bessel_func.cpp -o bessel_func -lgsl -lm

In case it might need CBLAS features, you should also add `-lgslcblas':

$ g++ bessel_func.cpp -o bessel_func -lgsl -lgslcblas -lm

To learn more about linking in C and C++, you can see the following link (among 
many other resources):

https://www.gnu.org/software/gnuastro/manual/html_node/Linking.html

Or this more general discussion on understanding headers and libraries:

https://www.gnu.org/software/gnuastro/manual/html_node/Review-of-library-fundamentals.html

I hope this fixes your problem,
Cheers,
Mohammad

On January 1, 2018 3:26:28 PM GMT+01:00, Mohammadamin Izadi <address@hidden> 
wrote:
>Hello
>I want to use GSL for my project.
>I downloaded the version 2.4 from your site and use these commands
>according to install file
>sudo su
>./configure
>make
>make check
>make install
>----------------------------------------------------------
>the file gsl exists in "/usr/local/include" .
>----------------------------------------------------------
>but when I want to compile this code by "make":
>#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 message appears :
>g++     bessel_func.cpp   -o bessel_func
>/tmp/ccZymBuK.o: In function `main':
>bessel_func.cpp:(.text+0x23): undefined reference to `gsl_sf_bessel_J0'
>collect2: error: ld returned 1 exit status
><builtin>: recipe for target 'bessel_func' failed
>make: *** [bessel_func] Error 1
>
>----------------------------------------------------------------------------------
>I use ubuntu 16.0.4 64 bit and g++
>
>I hope you have enough time to answer me.
>Thanks in advance.
>Best regards.


reply via email to

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