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]

help!


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



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