[Trilinos-Users] FW: building with shared libraries

Bill Hoffman bill.hoffman at kitware.com
Thu Oct 8 13:16:47 MDT 2009

Jason Slemons wrote:
> Brent,
> I think I haven’t been explaining my problem well. I am building a 
> Teuchos test function and in the link step (when linking with libraries 
> like BLAS, which is in ‘lsci’ or ‘lsci_quadcore’ below) I get the 
> following error:
> Linking CXX executable Teuchos_BLAS_test.exe
> cd 
> /home/users/slemons/trilinos/trilinos-10.0-Source/gnu.BUILD/packages/teuchos/test/BLAS 
> && /home/users/slemons/cmake-2.9.20091007-Linux-i386/bin/cmake -E 
> cmake_link_script CMakeFiles/Teuchos_BLAS_test.dir/link.txt --verbose=1
> /opt/cray/xt-asyncpe/3.4.7/bin/CC    -DHAVE_MPI_CXX 
> CMakeFiles/Teuchos_BLAS_test.dir/cxx_main.cpp.o  -o 
> Teuchos_BLAS_test.exe -rdynamic 
> -L/home/users/slemons/trilinos/trilinos-10.0-Source/gnu.BUILD/packages/teuchos/src 
> ../../src/libteuchos.a -Wl,-Bstatic -lsci_quadcore -lsci -lsci_quadcore 
> -lsci -*Wl,-Bdynamic* 
> -Wl,-rpath,/home/users/slemons/trilinos/trilinos-10.0-Source/gnu.BUILD/packages/teuchos/src
> /opt/cray/xt-asyncpe/3.4.7/bin/CC: INFO: linux target is being used
> /opt/xt-libsci/ undefined reference to 
> `dfftw_execute_dft_'
> I think this error is caused by the fact that libsci.so is linked  and 
> it requires the dfftw_execute_dft function. “–Wl, -Bdynamic” (in bold 
> above) I believe causes the compiler to grab the dynamic libraries 
> libsci.so instead of libsci.a, which is what I would like. Is there some 
> way to make sure that –Bdynamic is never used at link time?

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.


More information about the Trilinos-Users mailing list