[Trilinos-Users] building with shared libraries and link flags
Jason Slemons
slemons at cray.com
Fri Oct 9 15:01:52 MDT 2009
An update for those of you following: the issue I was having below can be blamed on -Bdynamic showing up in the link line. While I'm not sure why -Bdynamic is showing up I do know that if you set
-D CMAKE_CXX_COMPILER_FLAGS:STRING="-Wl,-Bstatic"
-D Trilinos_EXTRA_LINK_FLAGS:STRING=-Wl,-Bstatic"
Then -Bstatic comes after -Bdynamic(which is important; I think the last one cancels all previous ones) and so forces it not to use .so files.
-Jason
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
------------------------------
_______________________________________________
Trilinos-Users mailing list
Trilinos-Users at software.sandia.gov
http://software.sandia.gov/mailman/listinfo/trilinos-users
End of Trilinos-Users Digest, Vol 50, Issue 11
**********************************************
More information about the Trilinos-Users
mailing list