我目前正在尝试使用 ARPACK++ 等其他 C++ 库,但在 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
这有点奇怪,因为包含头文件“ arerrorh.h ”被包裹在一个正确的里面:
#ifndef ARERROR_H
#define ARERROR_H
...
#endif
难道是我在链接或编译部分做错了什么?因为这几乎是我最不自信的部分。如果有人能告诉我我在这里做错了什么,我会很高兴。
提前致谢!