Use gsl on Mac 10.6.3
I recently have a project using GSL. After I installed the GSL package on Mac 10.6.3. I cannot compile my code.
The gsl lib is located at /usr/local/lib, and the head file located at /usr/local/.
When I compile my code I get the the following error. If I do not specify "-m32" in the makefile, it still gives the same error, just change "i386" to "x86_64". Can anyone help me?
Thank you!
#include <gsl/gsl_vector.h>
#include <gsl/gsl_multiroots.h>
By the way, should I include gsl like the above? actually I am quite new to programming.
Undefined symbols for architecture i386:
"_gsl_vector_get", referenced from:
gsl_root_finding::print_state(unsigned long, gsl_multiroot_fdfsolver*)in test_guide.o
gsl_root_finding::print_state(unsigned long, gsl_multiroot_fsolver*)in test_guide.o
gsl_root_finding::mm_f(gsl_vector const*, void*, gsl_vector*)in test_guide.o
gsl_root_finding::process(int, double*, double, double)in test_guide.o
gsl_root_finding::mm_fdf(gsl_vector const*, void*, gsl_vector*, gsl_matrix*)in test_guide.o
gsl_root_finding::mm_df(gsl_vector const*, void*, gsl_matrix*)in test_guide.o
"_gsl_vector_set", referenced from:
gsl_root_finding::mm_f(gsl_vector const*, void*, gsl_vector*)in test_guide.o
gsl_root_finding::process(int, double*, double, double)in test_guide.o
gsl_root_finding::mm_fdf(gsl_vector const*, void*, gsl_vector*, gsl_matrix*)in test_guide.o
gsl_root_finding::mm_df(gsl_vector const*, void*, gsl_matrix*)in test_guide.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [test_guide] Error 1
The bui开发者_StackOverflow社区ld code:
CC = g++
OPT = -pg -g -I../include -L../libs -I../../Matrix-1.0/include -I../../bessel-1.1/include -L../../Matrix-1.0/libs -L../../bessel-1.1/libs -L/usr/local/lib
LIBS = -lfmm -lssi -lsparse -lbessel -lg2c -lgfortran -lgsl
.SUFFIXES : .o .cpp
test_guide: test_guide.o
${CC} -o $@ ${OPT} test_guide.o ${LIBS}
I'm not sure, but I think you'll need to link with GSL's BLAS library as well. Your x86_64 undefined reference seems to imply as much (blas.o is the hint I'm going on). Just add
-lgslcblas
to your LIBS variable.
精彩评论