【发布时间】:2012-03-14 21:00:15
【问题描述】:
我正在尝试编译以下代码:http://www-personal.umich.edu/~mejn/dcbm/KLOptimization.cpp
但我从 g++ 收到以下错误消息:
> Undefined symbols for architecture x86_64: "_gsl_rng_uniform_int",
> referenced from:
> Initialize() in ccDEqovL.o
> _main in ccDEqovL.o "_gsl_rng_default_seed", referenced from:
> _main in ccDEqovL.o "_gsl_rng_default", referenced from:
> _main in ccDEqovL.o "_gsl_rng_alloc", referenced from:
> _main in ccDEqovL.o "_gsl_rng_name", referenced from:
> _main in ccDEqovL.o "_gsl_rng_get", referenced from:
> _main in ccDEqovL.o "_gsl_rng_uniform", referenced from:
> _main in ccDEqovL.o "ComputeVI()", referenced from:
> _main in ccDEqovL.o "ComputeNMI()", referenced from:
> _main in ccDEqovL.o "_gsl_rng_free", referenced from:
> _main in ccDEqovL.o ld: symbol(s) not found for architecture x86_64
我有运行 iOS 10.7.3 的 MacBook Air。 g++ 是 i686-apple-darwin11-llvm-g++-4.2。
我使用“brew install gsl”安装了 GSL,它给出了以下输出:
==> Downloading http://ftpmirror.gnu.org/gsl/gsl-1.15.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gsl/1.15
==> make
==> make install
Warning: m4 macros were installed to "share/aclocal".
Homebrew does not append "/usr/local/share/aclocal"
to "/usr/share/aclocal/dirlist". If an autoconf script you use
requires these m4 macros, you'll need to add this path manually.
==> Summary
/usr/local/Cellar/gsl/1.15: 237 files, 7.0M, built in 81 seconds
【问题讨论】:
-
_gsl_rng_uniform_int在什么对象中?您是否将其与ccDEqovL.o链接? -
您好像忘记链接 GSL 库了。编译时你的命令行是否包含
-lgsl(我相信这是需要的)? -
...只是因为我有时觉得问这个愚蠢的问题很有用 - 事实上,你有没有手动将路径“/usr/local/share/aclocal”添加到“/usr/share /aclocal/dirlist”?
-
我错过的是 -lgsl 标志。但是关于“愚蠢的问题”,我实际上错过了它,但它并没有改变任何东西。将您的评论添加为答案 Ken,我会将其标记为正确。非常感谢:)。
标签: c++ macos compilation gsl