Trouble linking Trilinos shared libraries

Asked by Robert Caulk

Hello Yade community,

I am trying to incorporate some tools from the Trilinos tool box into yade, but I am running into an issue with linking shared libraries. If you have any experience linking shared libraries with yade (or other software), I would greatly appreciate some advice here.

The process follows:

-Compile Trilinos as shared libraries
-Add a "FindTrilinos.cmake" and modify CMakeLists.txt (see below)
-Compile Yade (successfully)
-Run a test with the new yade installation and I receive the following error:

Traceback (most recent call last):
  File "/home/rcaulk/YADE/buildYade/interactiondistribution/install/bin/yade-2017-05-24.git-0ade6cf", line 129, in <module>
    import yade
  File "/home/rcaulk/YADE/buildYade/interactiondistribution/install/lib/x86_64-linux-gnu/yade-2017-05-24.git-0ade6cf/py/yade/__init__.py", line 65, in <module>
    import boot
ImportError: libteuchoscomm.so.12: cannot open shared object file: No such file or directory
_____________________________________________________________________

But libteachoscomm.so.12 is a file and it is in the following directory:
/usr/local/lib/trilinos2/install/lib/

I believe this directory is linked using the following (selected) commands in FindTrilinos.cmake:

SET(TRILINOS_LIB_SEARCH_PATH /usr/local/lib/trilinos2/install/lib)

FIND_LIBRARY(TEUCHOS_LIBRARY_COMM NAMES teuchoscomm PATHS ${TRILINOS_LIB_SEARCH_PATH})

IF(TEUCHOS_INCLUDE_PATH AND TEUCHOS_LIBRARY)
 SET(TRILINOS_INCLUDE_DIR ${TRILINOS_INCLUDE_DIR} ${TEUCHOS_INCLUDE_PATH})
 SET(TRILINOS_LIBRARIES ${TRILINOS_LIBRARIES} ${TEUCHOS_LIBRARY} ${TEUCHOS_LIBRARY_PARAMETER_LIST} ${TEUCHOS_LIBRARY_NUMERICS} ${TEUCHOS_LIBRARY_REMAINDER} ${TEUCHOS_LIBRARY_COMM})
 SET(HAVE_TEUCHOS YES)
ENDIF(TEUCHOS_INCLUDE_PATH AND TEUCHOS_LIBRARY)

and then in my CMakeLists.txt:

IF(ENABLE_TRILINOS)
  FIND_PACKAGE(Trilinos)
  IF (TRILINOS_FOUND)
    INCLUDE_DIRECTORIES(${TRILINOS_INCLUDE_DIR})
    LINK_DIRECTORIES(${TRILINOS_LIBRARIES})
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTRILINOS")
    SET(LINKLIBS "${LINKLIBS};${TRILINOS_LIBRARIES};")
    SET(CONFIGURED_FEATS "${CONFIGURED_FEATS} TRILINOS")
    MESSAGE("Adding Trilinos")
  ELSE(TRILINOS_FOUND)
    MESSAGE(STATUS "TRILINOS NOT found")
    SET(DISABLED_FEATS "${DISABLED_FEATS} TRILINOS")
    SET(ENABLE_TRILINOS OFF)
  ENDIF(TRILINOS_FOUND)
ELSE(ENABLE_TRILINOS)
  SET(DISABLED_FEATS "${DISABLED_FEATS} TRILINOS")
ENDIF(ENABLE_TRILINOS)
_____________________________________________________________________

The cmake step is successful, and so is the following make and installation of yade.

I am almost certain my problem lies in the CMakeList.txt file. I am linking here as if these are static libraries? But I noticed other shared libraries are linked slightly differently? Notice I am not very familiar with why or if we need to link static vs shared libraries differently. I have tried to link these as shared libraries with:

    ADD_EXECUTABLE(yade ${SOURCES})
    TARGET_LINK_LIBRARIES(yade ${TRILINOS_LIBRARIES})

Instead of SET(LINKLIBS...) but cmake cries about yade not being an executable.

All help appreciated,

Robert

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Anton Gladky
Solved:
Last query:
Last reply:
Revision history for this message
Best Anton Gladky (gladky-anton) said :
#1

Hi Robert,

as a workaround you can try to add
/usr/local/lib/trilinos2/install/lib/ into LD_LIBRARY_PATH.

export LD_LIBRARY_PATH=/usr/local/lib/trilinos2/install/lib/:$LD_LIBRARY_PATH

It should help your operating system to find the shared library.
Long-term solution would be
to use the package trllinois [1]. You can choose exactly the needed
library (there are a lot of
them) and escape LD_LIBRARY_PATH hack.

[1] https://tracker.debian.org/pkg/trilinos

Best regards

Anton

2017-05-28 5:23 GMT+02:00 Robert Caulk <email address hidden>:
> Question #635850 on Yade changed:
> https://answers.launchpad.net/yade/+question/635850
>
> Description changed to:
> Hello Yade community,
>
> I am trying to incorporate some tools from the Trilinos tool box into
> yade, but I am running into an issue with linking shared libraries. If
> you have any experience linking shared libraries with yade (or other
> software), I would greatly appreciate some advice here.

Revision history for this message
Robert Caulk (rcaulk) said :
#2

Thanks Anton Gladky, that solved my question.