我已经在 Ubuntu 14.10 中安装了 Armadillo。我有一个示例代码,如下所示
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int main(int argc, char** argv)
{
mat A = randu<mat>(4,5);
mat B = randu<mat>(4,5);
cout << A*B.t() << endl;
return 0;
}
我在命令行编译,总是成功,我在捕获的图像中描绘。
我有 C++ 的 eclipse Luna 和 C/C++ build设置中的配置
如您所见,它类似于命令行,但在 eclipse 编译时,它使用 -Iarmadillo
而不是 -larmadillo
然后它会发生错误。
错误是
make all Building file: ../src/Test.cpp Invoking: GCC C++ Compiler g++ -std=c++0x -Iarmadillo -O0 -MMD -MP -MF"src/Test.d" -MT"src/Test.d" -o "src/Test.o" "../src/Test.cpp" /tmp/ccy9M8WG.o: In function
void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)': Test.cpp:(.text._ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_[_ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_]+0x55): undefined reference to
wrapper_dgemv_' /tmp/ccy9M8WG.o: In functionvoid arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)': Test.cpp:(.text._ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_[_ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_]+0x5b): undefined reference to
wrapper_dgemm_' /tmp/ccy9M8WG.o: In functionvoid arma::blas::syrk<double>(char const*, char const*, int const*, int const*, double const*, double const*, int const*, double const*, double*, int const*)': Test.cpp:(.text._ZN4arma4blas4syrkIdEEvPKcS3_PKiS5_PKT_S8_S5_S8_PS6_S5_[_ZN4arma4blas4syrkIdEEvPKcS3_PKiS5_PKT_S8_S5_S8_PS6_S5_]+0x4e): undefined reference to
wrapper_dsyrk_' /tmp/ccy9M8WG.o: In functiondouble arma::blas::dot<double>(unsigned int, double const*, double const*)': Test.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[_ZN4arma4blas3dotIdEET_jPKS2_S4_]+0x4a): undefined reference to
wrapper_ddot_' /tmp/ccy9M8WG.o: In functionTLS wrapper function for arma::arma_rng_cxx11_instance': Test.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x5): undefined reference to
TLS init function for arma::arma_rng_cxx11_instance' Test.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x15): undefined reference to `arma::arma_rng_cxx11_instance' collect2: error: ld returned 1 exit status src/subdir.mk:18: recipe for target 'src/Test.o' failed make: *** [src/Test.o] Error 1
我的问题是
- 如何强制 eclipse 使用 -larmadillo?
- 这种现象是怎么回事?
提前致谢
最佳答案
您还可以创建 GNU Autotools
项目并添加以下行:
bin_PROGRAMS=armadillo_example
armadillo_example_SOURCES=armadillo_example.cpp
armadillo_example_LDADD=-larmadillo
到您的源代码所在的 Makefile.am 文件。
关于c++ - Armadillo 与 Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29191702/