0

我正在尝试使用 Trilino 包编译一个简单的测试程序,但是出了点问题。据我所知,Trilino 的安装进展顺利,但链接肯定有问题。下面是我的makefile:

include /home/jacob/Trilinos/trilinos-build/Makefile.export.Trilinos
CXX=$(Trilinos_CXX_COMPILER)
CC=$(Trilinos_C_COMPILER)
FORT=/usr/bin/gfortran

CXX_FLAGS=$(Trilinos_CXX_COMPILER_FLAGS) $(USER_CXX_FLAGS)
C_FLAGS=$(Trilinos_C_COMPILER_FLAGS) $(USERC_FLAGS)
FORT_FLAGS=$(Trilinos_Fortran_COMPILER_FLAGS) $(USER_FORT_FLAGS)

INCLUDE_DIRS=$(Trilinos_INCLUDE_DIRS) $(Trilinos_TPL_INCLUDE_DIRS)
LIBRARY_DIRS=$(Trilinos_LIBRARY_DIRS) $(Trilinos_TPL_LIBRARY_DIRS)
LIBRARIES=$(Trilinos_LIBRARIES) $(Trilinos_TPL_LIBRARIES)

LINK_FLAGS=$(Trilinos_EXTRA_LD_FLAGS)
DEFINES=-DMYAPP_EPETRA

default: print_info vector.x 

vector.x: libmyappLib.a
      $(CXX) $(CXX_FLAGS) libMyappLib.a -o vector.x $(LINK_FLAGS) $(INCLUDE_DIRS) $(DEFINES) $(LIBRARY_DIRS) $(LIBRARIES)

libmyappLib.a: es.o
      $(Trilinos_AR) cr libMyappLib.a es.o

es.o:
      $(CXX) -c $(CXX_FLAGS) $(INCLUDE_DIRS) $(DEFINES) es.cpp

这是程序:

#include "Epetra_SerialComm.h"
#include "Epetra_Map.h"
#include "Epetra_Vector.h"
#include "Epetra_Version.h"

int main(int argc, char *argv[])
{

std::cout << Epetra_Version() << std::endl << std::endl;
Epetra_SerialComm Comm;
int NumElements = 1000;
Epetra_Map Map(NumElements, 0, Comm);
Epetra_Vector x(Map);
Epetra_Vector b(Map);
b.Random();
x.Update(2.0, b, 0.0); // x = 2*b
double bnorm, xnorm;
x.Norm2(&xnorm);
b.Norm2(&bnorm); 
std::cout << "2 norm of x = " << xnorm << std::endl
          << "2 norm of b = " << bnorm << std::endl;

return 0;
}

然而,当运行 make 它只是返回:

es.cpp:(.text.startup+0x91): undefined reference to Epetra_SerialComm::Epetra_SerialComm()
es.cpp:(.text.startup+0xa7): undefined reference to           `Epetra_Map::Epetra_Map(int,int, Epetra_Comm const&)'
es.cpp:(.text.startup+0xbb): undefined reference to `Epetra_Vector::Epetra_Vector(Epetra_BlockMap const&, bool)'
.
.
.
collect2: error: ld returned 1 exit status
make: *** [vector.x] Fel 1

对于 main 中的每一段代码,即使它没有抱怨包含的内容,它似乎也找不到 Epetra 包。有谁知道可能是什么问题?我对 C++/C 相当陌生,处理 Trilino 包相当复杂,因此非常感谢任何提示。

4

0 回答 0