【问题标题】:How to compile my code and link with Trilinos libraries如何编译我的代码并链接到 Trilinos 库
【发布时间】:2013-02-21 23:38:54
【问题描述】:

我刚刚安装了 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 包中编译一些代码,但是我收到了与上述类似的错误)

谢谢

乔戈斯

【问题讨论】:

    标签: makefile cmake compilation linker trilinos


    【解决方案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,我会很感激这里的输入

    【讨论】:

    • 你用过this example吗?
    • 感谢您的发现!我使用了 Trilinos 的一个类似的,但没有太多解释性的 cmets。我试试看
    • 我是这样做的:将trilinos.sandia.gov/Export_Makefile_example.txt的内容复制到一个空的Makefile中。在以单词 include 开头的第一个命令中,您必须提供安装的“Makefile.export.Trilinos”文件的路径。接下来将库和源文件的名称更改为正确的名称并执行 make “MyApp.exe”,其中“MyApp.exe”是您用来替换 Makefile 中的“MyApp.exe”的名称。我希望这会有所帮助。
    【解决方案2】:

    您可以使用 cmakemake 使用 Trilinos 构建您的程序。推荐你去官方教程网站here,里面对这两种方法都有详细的解释。

    【讨论】:

      猜你喜欢
      • 2011-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多