【问题标题】:Use gsl on Mac 10.6.3在 Mac 10.6.3 上使用 gsl
【发布时间】:2011-08-20 18:36:49
【问题描述】:

我最近有一个使用 GSL 的项目。在我在 Mac 10.6.3 上安装 GSL 包之后。我无法编译我的代码。

gsl 库位于 /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 $@ ${OPT} test_guide.o ${LIBS} 

【问题讨论】:

  • 您用于构建程序的确切命令是什么?
  • 你好@Bavarious 我附上了构建代码,希望你能找出问题所在。提前谢谢你

标签: c++ macos precompiled-headers gsl


【解决方案1】:

我不确定,但我认为您还需要链接 GSL 的 BLAS 库。您的 x86_64 未定义引用似乎暗示了很多(blas.o 是我要继续的提示)。只需添加

-lgslcblas

到您的 LIBS 变量。

【讨论】:

  • 我也遇到了同样的问题。我到底在哪里添加 -lgslcblas?我通过在 /usr/local/lib 中找到库并将其手动添加到项目中来解决了一些问题。
  • LIBS 变量之后的makefile 中,或者在XCode 中我不知道的某个地方。我对 Mac 不熟悉。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-02
  • 2011-02-21
  • 1970-01-01
  • 2018-07-06
  • 2011-11-10
相关资源
最近更新 更多