本文介绍了在NeatBeans上使用Armadillo库编译c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将编译包含Armadillo库的C ++程序.通过使用以下命令在命令行中可以解决此问题:

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

但是,当我在NetBeans项目的编译选项中添加-O1 -larmadillo时,会出现相当多的错误.

But when I add -O1 -larmadillo to the compile options of my NetBeans project I get a considerable amount of 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)

推荐答案

我知道这是一个老问题,但是最近我遇到了麻烦,因此如果有人遇到与我相同的问题,我想提供帮助.这是在64位Windows 7上的NetBeans C ++中设置Armadillo库的方法.

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.

  1. http://arma.sourceforge.net/download下载Armadillo的最新版本.html

将其解压缩到任何目录中.

Unpack it in some directory, where ever you want.

转到Netbeans->项目属性-> C ++编译器

Go to Netbeans -> Project Properties -> C++ Compiler

3.1包含目录->找到您的Armadillo目录,然后选择文件夹"include".

3.1 Include Directories -> find your Armadillo directory and select folder "include".

3.2预处理程序定义-> ARMA_USE_LAPACK ARMA_USE_BLAS

3.2 Preprocessor Definitions -> ARMA_USE_LAPACK ARMA_USE_BLAS

转到Netbeans->项目属性->链接器

Go to Netbeans -> Project Properties -> Linker

4.1其他库目录->找到您的Armadillo目录,然后选择文件夹"examples/lib_win64".

4.1 Additional Library Directories -> find your Armadillo directory and select folder "examples/lib_win64".

4.2其他依赖关系-> lapack_win64_MT.lib blas_win64_MT.lib

4.2 Additional Dependencies -> lapack_win64_MT.lib blas_win64_MT.lib

转到项目的文件夹,然后从Armadillo/examples/lib_win64添加文件.应该添加4个文件-> blas_win64_MT.dll,blas_win64_MT.lib,lapack_win64_MT.dll和lapack_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.

应该是这样.现在,您可以在C ++中使用Armadillo库,只需在cpp #include中添加,如果要使用名称空间arma;

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!

这篇关于在NeatBeans上使用Armadillo库编译c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 05:22