目前,我正试图与其他C++库(如ARPACK++ )一起工作,并且在ARPACK++的包含文件夹中遇到了多个定义问题。
这是我的编译行,其中包括我需要的几个库:
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这有点奇怪,因为include头"arerrorh.h“被包装在一个适当的文件中:
#ifndef ARERROR_H
#define ARERROR_H
...
#endif可能是我在链接或编译部分做错了什么吗?因为这是我最不自信的部分。如果有人能告诉我我在这里做错了什么,我会很高兴的。
提前感谢!
发布于 2014-08-13 20:14:15
头arerror.h中有一个错误。将inline放在ArpackError::Set函数的定义中。另外,请修复CSCMatrix::CreateARluSymMatrix方法,该方法返回局部变量的地址。
https://stackoverflow.com/questions/25295134
复制相似问题