2015-11-03 75 views
0

我想在Makefile中使用PGI编译器的-U__GNUG__标志,试图编译一个文件夹内的所有.cpp文件,链接到Armadillo(使用g ++编译器中,代码编译和运行),我有Makefile文件如下:Makefile使用PGI编译器链接到Armadillo库

CC=pgc++ 
CFLAGS= -U__GNUG__ -std=c++11 -fast -acc -Minfo=accel -larmadillo -lgsl -w 

all: 
    ${CC} ${CFLAGS} *.cpp -o cg 
clean: 
    rm -Rf cg pgprof* *.o core 

看来,对象文件的汇编工作,但未能编译最终的可执行文件。这个Makefile有什么问题?

编译使用的代码:

~$ make 

我收到以下错误:

cis.o: In function `arma::Col<double>::pod_type arma::op_norm::vec_norm_2<arma::Col<double> >(arma::Proxy<arma::Col<double> > const&, arma::arma_not_cx<arma::Col<double>::elem_type>::result const*)': 
/usr/local/include/armadillo_bits/debug.hpp:173: undefined reference to `isfinite' 
cis.o: In function `double arma::op_norm::vec_norm_2_direct_std<double>(arma::Mat<double> const&)': 
/usr/local/include/armadillo_bits/debug.hpp:173: undefined reference to `isfinite' 
cis.o: In function `void arma::arma_ostream::print_elem<double>(std::ostream&, double const&, bool)': 
/usr/local/include/armadillo_bits/debug.hpp:173: undefined reference to `isfinite' 
cis.o: In function `std::isfinite(double)': 
/usr/local/include/armadillo_bits/debug.hpp:173: undefined reference to `isfinite' 
cis.o: In function `bool arma::arma_isfinite<double>(double)': 
/usr/local/include/armadillo_bits/debug.hpp:173: undefined reference to `isfinite' 
davidson.o:davidson.cpp:(.gnu.linkonce.t._ZN4arma7op_norm10vec_norm_2INS_11subview_colIdEEEENT_8pod_typeERKNS_5ProxyIS4_EEPKNS_11arma_not_cxINS4_9elem_typeEE6resultE+0x2bb): more undefined references to `isfinite' follow 
pgacclnk: child process exit status 1: /usr/bin/ld 
make: *** [all] Error 2 

是应该由包括标志-U__GNUG__固定。

任何建议将不胜感激。

+0

是否使用你期望它用来编译你的二进制文件的命令? (您没有在粘贴的输出中包含该文件。) –

回答

0

这似乎是PGI pgC++编译器的一个问题,其中“std :: isfinite”在C++ 11的存在下未被正确处理。删除“ - C++ 11”标志将解决该问题。

我已经添加了一个问题报告,PGI TPR#22065,我们希望在未来的版本中解决该问题。

+0

感谢您的回答,但还有更多的问题,因为在使用pgC++编译它之后执行相同的代码时会产生错误的结果。任何想法? – user3116936

+0

不是手,但我的猜测是这两个问题是无关的。你可以发布一个小的复制例子来说明错误的答案吗? –