c++ - 未定义对 Armadillo 的 LAPACK 包装器的引用

标签 c++ linker lapack armadillo

我对 Armadillo 的使用有疑问。

我正在使用 Ubuntu 12.10 和 Code::Blocks 中的 gcc 编译器。 我使用 synaptic 包管理器安装了 LAPACK 和 BLAS。我还使用 synaptic 包管理器安装了一次 Armadillo ,一次是使用 CMake 手动安装的。 CMake 在为 Armadillo 编译进行配置时找到了 LAPACK 和 BLAS 库。此外,我在“Build Options”->“Linker”` 的 Code::Blocks 中链接了 BLAS 和 LAPACK 的库。

但是,每当我想要构建我的项目时,我都会收到错误消息:

 In function `void arma::lapack::getrf<double>(int*, int*, double*, int*, int*, int*)':|
/usr/include/armadillo_bits/lapack_wrapper.hpp|41|undefined reference to `wrapper_dgetrf_'|

明明是 Armadillo 找不到LAPACK,可是我做错了什么?

我还对 armadillo_bits/config.hpp 文件中的相应行进行了反注释,因此它看起来像这样:

    #if !defined(ARMA_USE_LAPACK)
    //#define ARMA_USE_LAPACK
    //// Uncomment the above line if you have LAPACK or a high-speed replacement for LAPACK,
    //// such as Intel MKL, AMD ACML, or the Accelerate framework.
    //// LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse.
    #endif

    #if !defined(ARMA_USE_BLAS)
    //#define ARMA_USE_BLAS
    //// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS,
    //// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate framework.
    //// BLAS is used for matrix multiplication.
    //// Without BLAS, matrix multiplication will still work, but might be slower.
    #endif

    /* #undef ARMA_USE_WRAPPER */
    //// Comment out the above line if you're getting linking errors when compiling your programs,
    //// or if you prefer to directly link with LAPACK and/or BLAS.
    //// You will then need to link your programs directly with -llapack -lblas instead of -larmadillo

当我尝试用整数设置矩阵时首先出现错误,所以

  Mat<int> element_nodes;

我将不胜感激有用的答案。我确实在互联网上搜索了几个小时。另外,如果您需要更多源代码,请告诉我。

最佳答案

看起来您安装了两个 Armadillo 拷贝,它们具有不同的配置。如有疑问,请将您的程序链接到:

g++ prog.cpp -o prog -O2 -larmadillo -llapack -lblas

您可能还想看看 Armadillo's FAQ和一个 previous Stackoverflow question .

关于c++ - 未定义对 Armadillo 的 LAPACK 包装器的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17062110/

相关文章:

c++ - 构建 CUDA/C++ 代码时链接器错误

c - GCC 忽略 __attribute__((section ("CCMRAM")))。怎么修?

c++ - Lapack 例程 dstev 中的段错误

c++ - clapack.h 或 Visual Studio 2008 中的模板数值工具包

c - 进入 DGEEV 参数编号 9 时有非法值

python - boost python enable_pickling 期望

c++ - 结构和类的嵌套

具有隔离键/值的 C++ 缓存友好 HashMap

C++ - 如何存储多维 vector ?

c++ - 如何像STL一样用c++制作一个库