c++ - Armadillo 与 Eclipse

标签 c++ eclipse armadillo

我已经在 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;
}

我在命令行编译,总是成功,我在捕获的图像中描绘。 enter image description here

我有 C++ 的 eclipse Luna 和 C/C++ build设置中的配置 enter image description here

如您所见,它类似于命令行,但在 eclipse 编译时,它使用 -Iarmadillo而不是 -larmadillo然后它会发生错误。 enter image description here

错误是

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 towrapper_dgemv_' /tmp/ccy9M8WG.o: In function void 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 towrapper_dgemm_' /tmp/ccy9M8WG.o: In function void 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 towrapper_dsyrk_' /tmp/ccy9M8WG.o: In function double arma::blas::dot<double>(unsigned int, double const*, double const*)': Test.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[_ZN4arma4blas3dotIdEET_jPKS2_S4_]+0x4a): undefined reference towrapper_ddot_' /tmp/ccy9M8WG.o: In function TLS wrapper function for arma::arma_rng_cxx11_instance': Test.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x5): undefined reference toTLS 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

我的问题是

  1. 如何强制 eclipse 使用 -larmadillo?
  2. 这种现象是怎么回事?

提前致谢

最佳答案

您还可以创建 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/

相关文章:

c++ - 使用 Boost 反序列化 Armadillo colvec

c++ - Armadillo : Can not find clapack. h

c++ - 在 C++ 中这种声明是什么意思?

c++ - 在 C++ 中使用 void 指针返回多个类型变量的最佳方法是什么?

c++ - 如何从 VirtualBox 日志文件中理解和调试?

eclipse - Java Eclipse 中的排序和排序库

java - 如何找到 "Plug-in Project"向导的源代码?

c++ - 什么是系统 ("CLS"的简单替代品)?

eclipse - 从 Java 调用 Clojure,他们说,这会很容易,他们说

c++ - Armadillo:高效的 RAM 稀疏批量插入