[CMake] static cmake, ctest executables

Ilias Miroslav Miroslav.Ilias at umb.sk
Sun Feb 5 10:24:59 EST 2012


Dear Eric,

yes, I would like to have static cmake execs for usage in (sometimes unequipped) grid environment;

I tried your buildup prescription, but got dynamic execs,

-------------
ilias at 194.160.135.47:~/bin/cmake_static/bin/.ldd * 
ccmake:
	linux-vdso.so.1 =>  (0x00007fff2e7c6000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f14516da000)
	libncurses.so.5 => /lib/libncurses.so.5 (0x00007f1451493000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f145118e000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1450f0c000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1450cf6000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1450971000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f14518fb000)
cmake:
	linux-vdso.so.1 =>  (0x00007fffff9ff000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1dd39db000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1dd


and  cmake's buildup step ignored the most importan flag:

------------------------------------------------------------
ilias at 194.160.135.47:~/bin/cmake_static/.cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS_DEBUG="-static"  /home/ilias/bin/cmake_static/cmake-2.8.7
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXE_LINKER_FLAGS_DEBUG


-- Build files have been written to: /home/ilias/bin/cmake_static
ilias at 194.160.135.47:~/bin/cmake_static/.cmake --version
cmake version 2.8.5
ilias at 194.160.135.47:~/bin/cmake_static/.
--------------------------

Any help, please ?

________________________________________
From: Eric Noulard [eric.noulard at gmail.com]
Sent: Saturday, February 04, 2012 10:59 AM
To: Ilias Miroslav; CMake ML
Subject: Re: [CMake] static cmake, ctest executables

2012/2/4 Ilias Miroslav <Miroslav.Ilias at umb.sk>:
> Greetings, Sirs,
>
>
> I would like to have "cmake" and "ctest" executables static (for usage in grid enviroment).
>
> I tried to compile the newest "cmake-2.8.7.tar.gz" version with
>
> ./configure --prefix=/home/ilias/bin/cmake_static LDFLAGS=--static --disable-shared --enable-static
>
> but still  got dynamic versions (see below), not static...

Fully static may be achieved with

cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS_DEBUG=-static
/path/to/source

I assume you compile CMake using cmake and not bootstrapping it.
CMAKE_EXE_LINKER_FLAGS_<BUILDTYPE> specifies an extra linker flags when building
executable.

Doing this spit warning like:

".../Utilities/cmcurl/hostip4.c:183: warning: Using 'gethostbyname_r'
in statically linked applications requires at runtime the shared
libraries from the glibc version used for linking"

If you dig into the CMake ML, I think you should find some discussion
about the issue
you may have to get fully static executable on Linux or more precisely
with glibc.

Stackoverflow has some entry on the subject as well:
http://stackoverflow.com/questions/3430400/linux-static-linking-is-dead

You may try to get rid of libgcc and libstdc++
using
-static-libgcc
and
-static-libstdc++

see
http://www.trilithium.com/johan/2005/06/static-libstdc/

Are you sure you really need fully static executable?

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list