[Trilinos-Users] FW: building with shared libraries

Jason Slemons slemons at cray.com
Thu Oct 8 15:22:42 MDT 2009


Hi Brent and Bill and everyone, 

So I'm not sure I'm following Bill; my knowledge of cmake is limited to its use in building trilinos.

First, shouldn't I set SCI_LIB to be the path and then use it as a variable?

set(SCI_LIB  /path/to/libsci_quadcore.a)
find_library(SCI_LIB NAMES libsci_quadcore.a)

...(what goes here?)...

target_link_libraries(Teuchos_BLAS_test SCI_LIB)

And should these go in my cmake script, or in CmakeLists.txt? Im guessing CMakeLists.txt, so I put them near the top. Then I ran my cmake script and got the following error and configure stops:

   Called from: [1]     /home/users/slemons/trilinos/trilinos-10.0-Source/CMakeLists.txt
/home/users/slemons/trilinos/trilinos-10.0-Source/CMakeLists.txt(8):  target_link_libraries(Teuchos_BLAS_test SCI_LIB )
   Called from: [1]     /home/users/slemons/trilinos/trilinos-10.0-Source/CMakeLists.txt
CMake Error at CMakeLists.txt:8 (target_link_libraries):
  Cannot specify link libraries for target "Teuchos_BLAS_test" which is not
  built by this project.
/opt/xt-libsci/10.4.0.2

So if I comment out the 'target_link_librarys' line my cmake script runs but when I 'make' it still trys to pick up the .so file.

Before I get too far though here is my cmake script that didn't work. it only refers to full paths and libsci_quadcore, and never lsci_quadcore:
cmake \
 -D TPL_ENABLE_LAPACK:BOOL=ON\
 -D TPL_ENABLE_BLAS:BOOL=ON\
 -D BLAS_LIBRARY_NAMES:STRING="libsci_quadcore.a "\
 -D LAPACK_LIBRARY_NAMES:STRING="libsci_quadcore.a "\
 -D BLAS_LIBRARY_DIRS:PATH=${LIBSCI_BASE_DIR}/${LC_PE_ENV}/lib${ext}\
 -D LAPACK_LIBRARY_DIRS:PATH=${LIBSCI_BASE_DIR}/${LC_PE_ENV}/lib${ext}\
 -D TPL_BLAS_LIBRARIES:FILEPATH="${LIBSCI_BASE_DIR}/${LC_PE_ENV}/lib${ext}/libsci_quadcore.a"\
 -D TPL_LAPACK_LIBRARIES:FILEPATH="${LIBSCI_BASE_DIR}/${LC_PE_ENV}/lib${ext}/libsci_quadcore.a"\
 -DCMAKE_CXX_FLAGS:STRING="-DHAVE_MPI_CXX -DMPICH_IGNORE_CXX_SEEK"\
 -D Trilinos_ENABLE_Teuchos:BOOL=ON\
 -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=OFF\
 -D Trilinos_ENABLE_TESTS:BOOL=ON\
 -D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF\
 -D Trilinos_VERBOSE_CONFIGURE:BOOL=ON --debug-output --trace\
 -D TPL_ENABLE_MPI:BOOL=ON \
 -D MPI_BASE_DIR:PATH="${MPICH_DIR}"\
 -D MPI_EXEC:FILEPATH="aprun"\
 -D BUILD_SHARED_LIBS:BOOL=OFF\
 -D CMAKE_VERBOSE_MAKEFILE:BOOL=TRUE\
 -D CMAKE_CXX_COMPILER:STRING="${ASYNCPE_DIR}/bin/CC"\
 -D CMAKE_C_COMPILER:STRING="${ASYNCPE_DIR}/bin/cc"\
 -D CMAKE_Fortran_COMPILER:STRING="${ASYNCPE_DIR}/bin/ftn"\
 -D DART_TESTING_TIMEOUT:STRING=600 \
 -D CMAKE_BUILD_TYPE:STRING=DEBUG \
 -D CMAKE_INSTALL_PREFIX:PATH=${base_dir}/trilinos.install.$$ \
 -D MPI_EXEC_NUMPROCS_FLAG:STRING=-n \
${tril_dir}


Thanks, 

--Jason




If you want CMake to use the .a, then you have to list out the full path 
to libsci.a when it is linked in.  Usually in CMake that would be 
something like this:

find_library(SCI_LIB NAMES sci)

...

target_link_libraries(Teuchos_BLAS_test ${SCI_LIB})

Where you made sure that SCI_LIB was the full path to the .a.  If you 
just give CMake a -lsci it will do what the linker does by default and 
that is to prefer the shared.

-Bill




More information about the Trilinos-Users mailing list