我想在Eclipse中使用Armadillo。然而,所有链接Armadillo的说明都是针对Visual Studio给出的。现在,我遵循了在ReadMe文件中列出的说明。犰狳图书馆. 我在 project(right click)->properties->C/C++ Build->Settings->Cross G++ Compiler->Includes->Inlcude paths(-I)
然后,我添加了库文件夹(库文件夹包含lapack和blas的.lib和.dll文件)在 project(right click)->properties->C/C++ Build->Settings->Cross G++ Linker->Libraries->Library search path (-L)
.
然而,当我在Eclipse中编译代码时,我得到的错误是
......armadillo_bitslapack_wrapper.hpp:37: undefined reference to `dgetrf_'.
是不是应该简单地在库文件夹中搜索.lib文件,并在编译过程中包含它们?如果有任何关于这个问题的帮助,我将感激不尽。
祝贺你,TM
将Armadillo库链接到Eclipse项目上是可以做到的,而且你马上就要做到了! 这和其他库的操作差不多。
在项目的属性中:
GCC C++ Compiler -> Includes : 添加文件的路径。armadillo
(其中namespace arma
声明)到包括搜索路径(选项-I)。例子:GCC C++ Linker -> GCC C++ Linker:添加文件的路径。/home/alpha/soft/armadillo-4.400.1/include
GCC C++ Linker -> Libraries : 添加文件的路径。libarmadillo.so...
在图书馆的搜索路径中(选项-L) 示例 。/home/alpha/soft/armadillo-4.400.1
. 添加 armadillo
, lapack
, blas
和 m
作为库(选项-l)。m
是为数学.
这里是eclipse产生的对编译器和链接器的调用。
make all
Building file: ../src/armaeclip.cpp
Invoking: GCC C++ Compiler
g++ -I/home/alpha/soft/armadillo-4.100.1/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/armaeclip.d" -MT"src/armaeclip.d" -o "src/armaeclip.o" "../src/armaeclip.cpp"
Finished building: ../src/armaeclip.cpp
Building target: armaeclip
Invoking: GCC C++ Linker
g++ -L/home/alpha/soft/armadillo-4.100.1 -o "armaeclip" ./src/armaeclip.o -larmadillo -lblas -lm -llapack
Finished building target: armaeclip
**** Build Finished ****
当你运行这段代码时,你可能会得到这样的信息: :
error: det(): use of ATLAS or LAPACK needs to be enabled terminate 调用后抛出一个'std::logic_error'实例 what(): det(): use of ATLAS or LAPACK needs to be enabled Abandon (core dumped)
为了避免这个问题,请遵循以下建议 犰狳的问题 :无意见 #define ARMA_USE_LAPACK
在档案中 /home/alpha/soft/armadillo-4.100.1/include/config.hpp
并重建您的项目。
您也可以创建GNU Autotools
并添加以下一行。
bin_PROGRAMS=armadillo_example
armadillo_example_SOURCES=armadillo_example.cpp
armadillo_example_LDADD=-larmadillo
至 Makefile.am
文件中存在你的源代码。
如果你不需要优化的BLAS库,你可以使用Armadillo自带的BLAS和LAPACK库。
C:\armadillo-x.xxx.x\include
C:\armadillo-x.xxx.x\examples\lib_win64\
Project properties > CC++ General > Paths and Symbols > Libraries:blas_win64_MT
和 lapack_win64_MT
(重要的是这样添加它们,没有路径或.lib.dll)
然后在环境变量> 系统变量中,修改Pathvariable并添加。C:\armadillo-x.xxx.x\examples\lib_win64\
然后你在Eclipse中的Armadillo库就可以使用了。
我用的是Eclipse 4.14.0和Armadillo 9.850.1。