[CMake] Is there a way to disable adding extra libraries at the end of a link line?

Chuck Atkins chuck.atkins at kitware.com
Wed Dec 30 11:04:22 EST 2015


Hi John,

Can you try using the new Cray platform file?  It should better handle the
implicit libs and dirs used by the compiler wrappers if you have the
appropriate modules loaded (cray-hdf5 for HDF5 libs, craype-sandybridge or
whatever your compute node CPU is for the -msse2 flag, etc.):

cmake -DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment /path/to/source

It's not available in a release yet so you'll need to build cmake from the
git master branch to try it.  Just be sure to build cmake using the system
compilers, i.e. /usr/bin/gcc and /usr/bin/g++ on the login node and not the
Cray PrgEnv compiler wrappers.

- Chuck

On Fri, Dec 18, 2015 at 11:12 AM, JR Cary <cary at txcorp.com> wrote:

> Working on a just delivered Cray I am again challenged by the way that
> CMake adds libraries to the end of the link line that I did not specify.
>
> The Cray requires use of the compiler wrappers.  After adding the
> appropriate libraries (hdf5, z) to my target, the link line is
>
> /opt/cray/craype/2.4.2/bin/CC   -DMPICH_IGNORE_CXX_SEEK -std=c++11 -O3
> -DNDEBUG -msse2   CMakeFiles/io.dir/io.cxx.o  -o io
> -L/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib  ../libtxio.a
> ../../txstreams/libtxstreams.a
> /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a -Wl,-Bstatic -lz
> -Wl,-Bdynamic /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a
> -Wl,-Bstatic -lz -Wl,-Bdynamic
> -Wl,-rpath,/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib
>
> and the link fails with
>
> ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in
> `/usr/lib/../lib64/libc.a(strcmp.o)' can not be used when making an
> executable; recompile with -fPIE and relink with -pie
>
> Now I believe that Cray has the appropriate libraries in its compiler
> wrapper, because
> if I just link without all the additions:
>
> /opt/cray/craype/2.4.2/bin/CC   -DMPICH_IGNORE_CXX_SEEK -std=c++11 -O3
> -DNDEBUG -msse2   CMakeFiles/io.dir/io.cxx.o  -o io
> -L/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib  ../libtxio.a
> ../../txstreams/libtxstreams.a
> /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a  -lz
>
> it all just works.
>
> Is there a way to tell cmake not to append
> "-Wl,-Bdynamic /opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib/libhdf5.a
> -Wl,-Bstatic -lz -Wl,-Bdynamic
> -Wl,-rpath,/opt/cray/hdf5-parallel/1.8.14/INTEL/14.0/lib"
> to the link line and not to insert -Wl,-Bstatic in front of -lz
> ?
>
> Thx....John Cary
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151230/ad2fae44/attachment.html>


More information about the CMake mailing list