This is the mail archive of the
gsl-discuss@sourceware.cygnus.com
mailing list for the GSL project.
Re: Linking problem
- To: "Marcin Chady" <M dot Chady at cs dot bham dot ac dot uk>
- Subject: Re: Linking problem
- From: Brian Gough <bjg at network-theory dot co dot uk>
- Date: Sat, 8 Apr 2000 21:06:50 +0100 (BST)
- Cc: "Dirk Eddelbuettel" <edd at debian dot org>, <gsl-discuss at sourceware dot cygnus dot com>
- References: <001701bfa163$40f07d40$934d08c3@d0p8g5>
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
>
>