C ++:包括库,多个定义(ARPACK ++)

时间:2014-08-13 20:04:27

标签: c++ static-libraries arpack


我目前正在尝试使用其他C ++库,如ARPACK ++,并在ARPACK ++的include文件夹中遇到多个定义问题。
这是我的编译行,其中包括我需要的几个库:

 g++ -g -Dlinux -I/home/LapEVSol/arpack++/include -I/usr/local/include/g++-3 -o main main.cc Basis.cc IntegrationRule.cc Matrix.cc Mesh.cc PDE.cc /home/LapEVSol/arpack++/libsuperlu_4.3.a  /home/LapEVSol/arpack++/libarpack.a /home/LapEVSol/arpack++/liblapack.a /home/LapEVSol/arpack++/librefblas.a /home/LapEVSol/arpack++/libgfortran.a  -lm

编译器正在把这个错误交给我:

Matrix.cc: In member function ‘ARluSymMatrix<double>* CSCMatrix::CreateARluSymMatrix()’:
Matrix.cc:338:25: warning: address of local variable ‘MatrixName’ returned [-Wreturn-local-addr]
ARluSymMatrix<double> MatrixName(rows, nnz, entries, rowIndex, colPointer, 'L');
                     ^
/tmp/ccb6n5wo.o: In function `void std::_Destroy_aux<true>::__destroy<int*>(int*, int*)':
/home/LapEVSol/arpack++/include/arerror.h:163: multiple definition of `ArpackError::Set(ArpackError::ErrorCode, std::string const&)'
/tmp/ccR5YW3o.o:/home/LapEVSol/arpack++/include/arerror.h:163: first defined here
/tmp/ccb6n5wo.o: In function `void std::_Destroy_aux<true>::__destroy<int*>(int*, int*)':
/home/LapEVSol/arpack++/include/arerror.h:163: multiple definition of `ArpackError::code'
/tmp/ccR5YW3o.o:/home/LapEVSol/arpack++/include/arerror.h:163: first defined here
/tmp/ccpDlwxP.o: In function `__gnu_cxx::new_allocator<Mesh::Node>::new_allocator()':
/home/LapEVSol/arpack++/include/arerror.h:163: multiple definition of `ArpackError::Set(ArpackError::ErrorCode, std::string const&)'
/tmp/ccR5YW3o.o:/home/LapEVSol/arpack++/include/arerror.h:163: first defined here
/tmp/ccpDlwxP.o: In function `__gnu_cxx::new_allocator<Mesh::Node>::new_allocator()':
/home/LapEVSol/arpack++/include/arerror.h:163: multiple definition of `ArpackError::code'
/tmp/ccR5YW3o.o:/home/LapEVSol/arpack++/include/arerror.h:163: first defined here
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

这有点奇怪,因为包含标题&#34; arerrorh.h &#34;被包裹在一个适当的:

 #ifndef ARERROR_H
 #define ARERROR_H
 ...
 #endif

可能是我在链接或编译部分做错了吗?因为这几乎是我最不自信的部分。如果有人能告诉我这里我做错了什么,我会很高兴 提前谢谢!

1 个答案:

答案 0 :(得分:0)

标题arerror.h中有错误。将inline放在ArpackError::Set函数的定义中。另外,,修复CSCMatrix::CreateARluSymMatrix方法,该方法返回局部变量的地址。