问题
I am going to compile C++ program which contains Armadillo library. This issue is feasible via command line with this command:
g++ '/arm.cpp' -o example -O1 -larmadillo
But when I add -O1 -larmadillo to the compile options of my NetBeans project I get a considerable amount of errors.
I got these errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/atx/NetBeansProjects/armadillo'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/armadillo
make[2]: Entering directory `/home/atx/NetBeansProjects/armadillo'
mkdir -p dist/Debug/GNU-Linux-x86
g++ -O3 -o dist/Debug/GNU-Linux-x86/armadillo build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o: In function `gemv<double>':
/usr/include/armadillo_bits/blas_wrapper.hpp:79: undefined reference to `wrapper_dgemv_'
/usr/include/armadillo_bits/blas_wrapper.hpp:79: undefined reference to `wrapper_dgemv_'
/usr/include/armadillo_bits/blas_wrapper.hpp:79: undefined reference to `wrapper_dgemv_'
/usr/include/armadillo_bits/blas_wrapper.hpp:79: undefined reference to `wrapper_dgemv_'
build/Debug/GNU-Linux-x86/main.o: In function `gemm<double>':
/usr/include/armadillo_bits/blas_wrapper.hpp:114: undefined reference to `wrapper_dgemm_'
/usr/include/armadillo_bits/blas_wrapper.hpp:114: undefined reference to `wrapper_dgemm_'
/usr/include/armadillo_bits/blas_wrapper.hpp:114: undefined reference to `wrapper_dgemm_'
/usr/include/armadillo_bits/blas_wrapper.hpp:114: undefined reference to `wrapper_dgemm_'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/armadillo] Error 1
make[2]: Leaving directory `/home/atx/NetBeansProjects/armadillo'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/atx/NetBeansProjects/armadillo'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 136ms)
回答1:
I know this was an old question, but I had troubles recently with this so I want to help if someone else encounters same problems as I did. This is how-to setup Armadillo library in NetBeans C++ on 64 bit Windows 7.
Download the latest version of Armadillo from http://arma.sourceforge.net/download.html
Unpack it in some directory, where ever you want.
Go to Netbeans -> Project Properties -> C++ Compiler
3.1 Include Directories -> find your Armadillo directory and select folder "include".
3.2 Preprocessor Definitions -> ARMA_USE_LAPACK ARMA_USE_BLAS
Go to Netbeans -> Project Properties -> Linker
4.1 Additional Library Directories -> find your Armadillo directory and select folder "examples/lib_win64".
4.2 Additional Dependencies -> lapack_win64_MT.lib blas_win64_MT.lib
Go to your project's folder and add files from Armadillo/examples/lib_win64. 4 files should be added -> blas_win64_MT.dll, blas_win64_MT.lib, lapack_win64_MT.dll and lapack_win64_MT.lib.
This should be it. Now you can use Armadillo library in C++, just add in your cpp #include and if you want using namespace arma;
I hope this was helpful! Cheers!
回答2:
Looks like your Armadillo installation is incomplete, or you have two versions of Armadillo installed. I recommend that you manually uninstall any previous versions of Armadillo (both the includes and the run-time library) and then do a fresh install, using a freshly downloaded Armadillo .tar.gz package: http://arma.sourceforge.net/download.html
Alternatively, you can work around the issue you're having. Edit "include/armadillo_bits/config.hpp" and comment out the line with ARMA_USE_WRAPPER. Then, instead of linking with -larmadillo, link with -lblas -llapack
来源:https://stackoverflow.com/questions/10889629/compiling-c-with-armadillo-library-at-neatbeans