giorgk
giorgk

Reputation: 109

How to compile my code and link with Trilinos libraries

I've just installed trilinos 11.0.3 and now I'm trying to compile my first application using cmake.

The file I'm trying to compile is here http://code.google.com/p/trilinos/wiki/EpetraSimpleVector

The first command cmake seems to work although I get the following warnings (just in case its relevant) for each trilinos package:

    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.

Other than that it seems that the location of trilinos includes and libraries have been found correctly

However the make command produce a list of similar errors such as :

    /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)'

Any idea what's going on here?

(I named the source file teuchos_test.cpp because first I tried to compile some code from the teuchos package, However I was receiving similar errors as above)

Thank you

Giorgos

Upvotes: 1

Views: 1337

Answers (2)

F14
F14

Reputation: 73

You can use cmake or make to build your program with Trilinos. I refer you to the official tutorial website here, which provides detailed explanations for both methods.

Upvotes: 0

giorgk
giorgk

Reputation: 109

I haven't been able to compile the trilinos examples with cmake but I was able to do so by linking everything my self. For the example that gives me the above errors I did the following

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

since it depends on the epetra package only (I still have to change the name :))

However if anyone knows how to compile trilinos with cmake I'd appreciate the input here

Upvotes: -1

Related Questions