gpt4 book ai didi

c++ - Armadillo 与 Eclipse

转载 作者:太空宇宙 更新时间:2023-11-04 14:31:29 25 4
gpt4 key购买 nike

我已经在 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 to
wrapper_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 to
wrapper_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 to
wrapper_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 to
wrapper_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 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

我的问题是

  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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com