![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Programming Talk This forum is for all programming questions. The questions do not have to be directly related to Ubuntu and any programming language is allowed. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
5 Cups of Ubuntu
![]() Join Date: Aug 2005
Beans: 14
|
Undefined Reference for GSL library calls
Hey guys,
I'm in a bit of a time-bind, so I thought I'd ask here after spending 2 hours scouring the internet for an answer. I am using the GNU Science Library http://www.gnu.org/software/gsl/manu...ng-and-Linking After including the proper header files #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> After pressing Build in KDevelop or Anjuta, I'm getting errors like... undefined reference to `gsl_ran_multinomial' From what I've read, it's something about linking? I'm used to good ol' java and visual studio, so I have no clue what to do. Thanks for your patience! |
|
|
|
|
|
#2 |
|
Fresh Brewed Ubuntu
![]() |
Re: Undefined Reference for GSL library calls
You are correct, it is a linking issue. I'm not sure how to specify external libraries in Kdevelop or Anjunta, but on the command line you would do this:
Code:
gcc myfile.c -lgsl You most likely will also want -lm (the math lib).
__________________
When I invented the Web, I didn't have to ask anyone's permission. ~Tim Berners-Lee on Net Neutrality ------------------------------------- Visit the Ubuntu Programming IRC-channel at #ubuntu-programming (chat.freenode.net). |
|
|
|
|
|
#3 |
|
5 Cups of Ubuntu
![]() Join Date: Jun 2008
Beans: 16
|
Re: Undefined Reference for GSL library calls
Hello, I had the same problem. I tried compiling with -lgsl and I got a bunch of errors. The errors were of the form:
/usr/lib/gcc/x86 64-linux-gnu/4.2.3/../../../../lib/libgsl.so undefined refernce to `cblas_csyrk' with the last part between the ` and the ' varying. Thanks in advance |
|
|
|
|
|
#4 |
|
Fresh Brewed Ubuntu
![]() Join Date: Oct 2004
Beans: 1,532
|
Re: Undefined Reference for GSL library calls
The best way to get the correct arguments to link the GSL library is with the pkg-config command:
Code:
$ pkg-config --libs gsl Code:
$ pkg-config --cflags gsl To compile and link a program that is contained in a single C file that uses GSL: Code:
$ gcc myprogram.c `pkg-config --cflags --libs gsl` -o myprogram Code:
$ gcc -c myprogram.c `pkg-config --cflags gsl` $ gcc myprogram.o `pkg-config --libs gsl` -o myprogram |
|
|
|
|
|
#5 |
|
First Cup of Ubuntu
![]() Join Date: Jun 2009
Beans: 1
|
Re: Undefined Reference for GSL library calls
Yes it works!
And, you can simply create a shell file to execute that compile and link statement. Give the o/p file as a.out if required. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|