在 Mac 10.6.3 上使用 gsl

发布于 2024-11-05 08:20:43 字数 1793 浏览 0 评论 0原文

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

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 $@ ${OPT} test_guide.o ${LIBS} 

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 build 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} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

定格我的天空 2024-11-12 08:20:43

我不确定,但我认为您还需要链接 GSL 的 BLAS 库。您的 x86_64 未定义引用似乎也暗示了这一点(blas.o 是我正在进行的提示)。只需添加

-lgslcblas

到您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文