This is the mail archive of the
gsl-discuss@sourceware.cygnus.com
mailing list for the GSL project.
Re: help!
- To: jin min ho <amaz@netra.lgic.co.kr>
- Subject: Re: help!
- From: Brian Gough <bjg@netsci.freeserve.co.uk>
- Date: Sun, 28 Feb 1999 20:20:12 +0000
- CC: gsl-discuss@sourceware.cygnus.com
- References: <36D74F16.5B4A9597@netra.lgic.co.kr>
Hi,
The library needs to be last on the command line so that it is searched
at the end of the link stage. If you use
gcc -I -I/usr/local/include -L/usr/local/lib rngtest.c -lgsl -o
rngtest.out
instead of
gcc -I -I/usr/local/include -L/usr/local/lib -lgsl rngtest.c -o
rngtest.out
then it should work.
regards
Brian Gough
jin min ho wrote:
>
> please help me with linking gsl!
> until i downloaded gsl-0.4.1 and installed it,it seemed that there was
> no problem with it.
> but when i link my first code to gsl rng, there was an link error.
> it repoted that "undefined reference to gsl_rng_env_setup and etc.
> it seemed that my gcc couldn't find gsl.
> here is my makefile and source code. what's wrong with my code ?
>
> ------------------------------------------------------------------------
>
> my linux box : redhat linux 5.2
> gcc version : 2.7.2.3
> egcs version : 1.0.3
>
> my gcc report :
>
> /tmp/cca017371.o: In function 'main':
> /tmp/cca017371.o(.text+0x4): undefined reference to 'gsl_rng_env_setup'
> /tmp/cca017371.o(.text+0x9): undefined reference to 'gsl_rng_default'
> /tmp/cca017371.o(.text+0xf): undefined reference to 'gsl_rng_alloc'
> /tmp/cca017371.o(.text+0x24): undefined reference to 'gsl_rng_name'
> /tmp/cca017371.o(.text+0x3c): undefined reference to 'gsl_rng_default_seed'
> /tmp/cca017371.o(.text+0x55): undefined reference to 'gsl_rng_get'
> make: *** [rngtest.out] Error 1
>
> my source code :
>
> #include <stdlib.h>
> #include <gsl_rng.h>
>
> gsl_rng *r;
>
> int main(void)
> {
> gsl_rng_env_setup();
> r = gsl_rng_alloc(gsl_rng_default);
>
> printf("generator type = %s\n", gsl_rng_name(r));
> printf("seed = %u\n", gsl_rng_default_seed);
> printf("first value = %u\n", gsl_rng_get(r));
>
> }
>
> my makefile
>
> ARCH = i386
> TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
>
> CROSS_COMPILE =
>
> AS =$(CROSS_COMPILE)as
> LD =$(CROSS_COMPILE)ld
> CC =$(CROSS_COMPILE)gcc -I$(HPATH)
> CPP =$(CC) -E
> AR =$(CROSS_COMPILE)ar
> NM =$(CROSS_COMPILE)nm
> STRIP =$(CROSS_COMPILE)strip
> MAKE =make
>
> GSL_INC_DIR = /usr/local/include
> GSL_LIB_DIR = /usr/local/lib
> GSL_LIB=gsl
>
> GSL_OPT = -I$(GSL_INC_DIR) -L$(GSL_LIB_DIR) -l$(GSL_LIB)
>
> all : rngtest.out
>
> rngtest.out : rngtest.c /usr/local/include/gsl_rng.h
> $(CC) $(GSL_OPT) $< -o $*.out
- References:
- help!
- From: jin min ho <amaz@netra.lgic.co.kr>