未定义参考Armadillo的LAPACK包装器

use*_*647 5 c++ linker lapack armadillo

我对犰狳的使用有疑问.

我正在使用Ubuntu 12.10,以及Code :: Blocks中的gcc编译器.我使用synaptic包管理器安装了LAPACK和BLAS.我还使用突触包管理器安装了一次Armadillo,一次是用CMake手动安装的.CMake在进行犰狳编译的配置时找到了LAPACK和BLAS库.此外,我在"构建选项" - >"链接器"中的代码::块中链接了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_'|
Run Code Online (Sandbox Code Playgroud)

这显然意味着犰狳找不到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
Run Code Online (Sandbox Code Playgroud)

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

  Mat<int> element_nodes;
Run Code Online (Sandbox Code Playgroud)

我很感激有用的答案.我在互联网上搜索了几个小时.此外,如果您需要更多源代码,请告诉我.

mta*_*all 2

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

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

您可能还想查看Armadillo 的常见问题解答之前的 Stackoverflow 问题