如何编译我的代码并与Trilinos库链接

时间:2013-03-06 23:03:20

标签: makefile cmake compilation linker trilinos

我刚刚安装了trilinos 11.0.3,现在我正在尝试使用cmake编译我的第一个应用程序。

我正在尝试编译的文件在这里 http://code.google.com/p/trilinos/wiki/EpetraSimpleVector

第一个命令cmake似乎有效,尽管每个trilinos包都会收到以下警告(以防相关):

    CMake Warning (dev) at /home/giorgos/Documents/TRILINOS/lib/cmake/Trilinos/
    TrilinosTargets.cmake:208 (ADD_LIBRARY):        
    ADD_LIBRARY called with SHARED option but the target platform does not
    support dynamic linking.  Building a STATIC library instead.  This may lead
    to problems.

除此之外,似乎trilinos的位置包括并且已经正确找到了库

但是make命令会生成类似错误的列表,例如:

    /home/giorgos/Documents/mpi_tests/trilinos_test/test1/src/teuchos_test.cpp:11:
    undefined reference to `Epetra_SerialComm::Epetra_SerialComm()'

    /home/giorgos/Documents/mpi_tests/trilinos_test/test1/src/teuchos_test.cpp:16: 
    undefined reference to `Epetra_Map::Epetra_Map(int, int, Epetra_Comm const&)'

    /home/giorgos/Documents/mpi_tests/trilinos_test/test1/src/teuchos_test.cpp:19: 
    undefined reference to `Epetra_Vector::Epetra_Vector(Epetra_BlockMap const&, bool)'

    /home/giorgos/Documents/mpi_tests/trilinos_test/test1/src/teuchos_test.cpp:20: 
    undefined reference to `Epetra_Vector::Epetra_Vector(Epetra_BlockMap const&, bool)'

知道这里发生了什么吗?

(我将源文件命名为teuchos_test.cpp,因为我首先尝试从teuchos包中编译一些代码,但是我收到了类似的错误,如上所述)

谢谢

Giorgos

2 个答案:

答案 0 :(得分:0)

您可以使用cmakemake通过Trilinos构建程序。我向您介绍了官方教程网站here,该网站提供了这两种方法的详细说明。

答案 1 :(得分:-1)

我无法使用cmake编译trilinos示例,但我能够通过链接我自己的一切来实现。对于给出上述错误的示例,我执行了以下操作

  g++ -o teuchos_test teuchos_test.cpp \ 
  -I/home/giorgos/Documents/TRILINOS/include \
  -L/home/giorgos/Documents/TRILINOS/lib -lepetra

因为它仅取决于epetra包(我仍然需要更改名称:))

但是如果有人知道如何用cmake编译trilinos我会很感激这里的输入