This is the mail archive of the gsl-discuss@sourceware.cygnus.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linking problem


If you are using version 0.5 or before then you will need to wrap any
includes with extern "C" to get the correct linkage.

   extern "C" {
   #include <gsl_foo.h>
   #include <gsl_bar.h>
   };

This behavior has been changed in CVS so that extern "C" will
not be necessary in future.

Marcin Chady writes:
 > Hi,
 > 
 > Sorry if this is a silly question, but I really can't work out what I'm
 > doing wrong.  I'm trying to use the random number suite from GSL, but I have
 > problems linking against libgslrng and libgslrandist.  It's a C++ program,
 > compiled with g++ 2.95.2, on a Debian Linux PC, running kernel 2.2.1, libc6
 > 2.1.3.  The compilation goes fine, but at the linking stage:
 > 
 > g++ -I/usr/include/gsl -MMD -O Config.o Exception.o Random.o Distribution.o
 > distributions.o -L/usr/lib/gsl -lgslsys -lgslerr -lgslspecfunc -lgslrng -lgs
 > lrandist -o distributions
 > 
 > I get errors like this:
 > 
 > Random.o: In function `__static_initialization_and_destruction_0':
 > Random.o(.text+0x28): undefined reference to `gsl_rng_env_setup(void)'
 > (...more of the kind...)
 > Random.o: In function `Uniform::next(void)':
 > Random.o(.Uniform::gnu.linkonce.t.next(void)+0x10): undefined reference to
 > `gsl_rng_uniform(gsl_rng const *)'
 > (...more of the kind...)
 > distributions.o: In function `main':
 > distributions.o(.text+0x1ca6): undefined reference to
 > `gsl_rng_env_setup(void)'
 > (...more of the kind...)
 > collect2: ld returned 1 exit status
 > make: *** [distributions] Error 1
 > 
 > Can you help please?
 > 
 > Marcin
 > 
 > 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]