2011-05-07 64 views
0

我最近有一個使用GSL的項目。在Mac 10.6.3上安裝GSL包後。我無法編譯我的代碼。在Mac上使用gsl 10.6.3

gsl lib位於/ usr/local/lib,頭文件位於/ usr/local /。

當我編譯我的代碼時,我得到以下錯誤。如果我沒有在makefile中指定「-m32」,它仍會給出相同的錯誤,只需將「i386」更改爲「x86_64」即可​​。誰能幫我?

謝謝!

#include <gsl/gsl_vector.h> 
#include <gsl/gsl_multiroots.h> 

順便說一句,我應該包括像上面那樣的gsl嗎?其實我對編程頗爲陌生。

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 

構建代碼:

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 [email protected] ${OPT} test_guide.o ${LIBS} 
+0

您用於構建程序的確切命令是什麼? – 2011-05-08 05:14:09

+0

你好@Bavarious我附上了構建代碼,並希望你能弄清楚這個問題。預先感謝您 – 2011-05-08 11:38:34

回答

2

我不知道,但我認爲你需要與GSL的BLAS庫以及鏈接。您的x86_64未定義參考似乎意味着儘可能多(blas.o是我正在進行的提示)。只需添加

-lgslcblas 

到您的LIBS變量。

+0

謝謝@rubenvb。它通過添加-lgslcblas來工作。 – 2011-05-09 09:17:11

+0

我有這個相同的問題。我在哪裏添加-lgslcblas ?.我通過在/ usr/local/lib中找到庫並將其手動添加到項目中做了一些瑣碎的工作。 – Eytan 2011-06-30 19:37:31

+0

在'LIBS'變量之後的makefile中,或者在XCode中我不知道的地方。我對Mac不熟悉。 – rubenvb 2011-06-30 19:39:12