[Trilinos-Users] FW: building with shared libraries

Perschbacher, Brent M bmpersc at sandia.gov
Thu Oct 8 16:06:31 MDT 2009


This is a very interesting problem actually. Your link line also has -Wl,-Bstatic on it(I marked it red in you message below). I'm not sure which set of options controls doing a shared build with the cray compilers but it also has -rdynamic, -rpath and -fpic on the link line so it looks like it is doing everything short of "-shared" for a shared build (assuming that the options are identical to gcc). I noticed these same options on a serial build of mine on a linux machine with gcc4.1.2 that I know wasn't supposed to be shared so I am a little confused here too. I will be looking into this on our side, cause I don't think those options should be there on a static build period.

In the mean time there are a couple of options you can try. You can put "-static" in CMAKE_C_COMPILER_FLAGS and CMAKE_CXX_COMPILER_FLAGS if you are using a configure script like in the sampleScripts dir that should just be:

-D CMAKE_C_COMPILER_FLAGS:STRING=-static
-D CMAKE_CXX_COMPILER_FLAGS:STRING=-static

You can try overridding the options completely. There is a description of how to do this in the TrilinosCMakeQuickStart.txt file in the cmake directory. Though I'm not sure that either of those will fix this since the -Wl,-Bdynamic is later on the command line, I'm not sure if -static overrides all other options or if it is last seen wins. The very last option would be to try setting the extra link flags option. Again if you are using a script it would be something like:

-D Trilinos_EXTRA_LINK_FLAGS:STRING=-static


That should put -static as the absolute last thing on the link line for every executable you build.

Let us know if those options don't work for you. I can't think of another work around off the top of my head, but I can certainly dig a bit more to see if there is another option.

Brent


On 10/8/09 12:26 PM, "Jason Slemons" <slemons at cray.com> 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 -DMPICH_IGNORE_CXX_SEEK -g -O0  -fPIC 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/10.4.0.2/gnu/lib/44/libsci.so: 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?

-Jason


From: Perschbacher, Brent M [mailto:bmpersc at sandia.gov]
Sent: Thursday, October 08, 2009 8:32 AM
To: Jason Slemons; trilinos-users at software.sandia.gov
Subject: Re: [Trilinos-Users] FW: building with shared libraries

Right now building trilinos as shared objects is not the default so as long as you don't turn it on you will have static libraries. You can verify this by looking at the cmake cache variable "BUILD_SHARED_LIBS" either in the gui or by searching through the CMakeCache.txt file that is generated by the configure process. It should be set to "OFF" for static builds. There are some platforms/compilers where shared builds are the standard (sun comes to mind, maybe windows too) which might be where the the comment about automatically turning on of shared comes from. If you aren't on a system like that then static should be what you get. If you want to make 100% sure that your builds are always static you could set BUILD_SHARED_LIBS to off in your configure scripts, that should override any system default that may make the build shared. None of our testing platforms default to shared so I can't say I've tried that case though.

Brent


On 10/7/09 5:52 PM, "Jason Slemons" <slemons at cray.com> wrote:

Hello,

Is building trilinos packages using shared libraries(for example TPLs) something that happens automatically? I read online that it might be and it looks like in cmake/TODO there is a bullet about making it default. I would like to know how to make sure that only static libraries are used to build trilinos(esp the tests in various packages) since my executables are going to be running on nodes without the libraries, and only on my build machine will I have access to all the Third Party Libraries.

-Jason

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20091008/51e9bb96/attachment.html 


More information about the Trilinos-Users mailing list