[CMake] statically linked executables
Bill Hoffman
bill.hoffman at kitware.com
Mon Dec 3 07:42:10 EST 2007
Oliver Dole wrote:
> 2007/11/27, Daniel Rueckert <dr at doc.ic.ac.uk>:
>> Hi,
>>
>> I am trying to build some statically linked executables on a linux
>> box. I have added the "-static" option to the linker flags and specified
>> static link libraries but for some reason cmake still adds the option
>> "-Wl,-Bdynamic" flag to the linker options. Is there any way around this?
>>
>> Thanks, Daniel
> Hello,
>
> I exactly face the same problem with cmake-2.4.6:
> http://www.sand-labs.org/owb/ticket/160
> But I assure that it perfectly worked with cmake-2.4.3. So is there a
> regression between cmake-2.4.3 and cmake-2.4.6 or a new way to manage
> static link that I have missed (and so my CMakeFiles are not valid
> anymore)?
>
A change was made to make sure that CMake picks the libraries you
specified. So, if you have /usr/lib/libfoo.so, CMake will add
-Wl,-dynamic -lfoo around foo. But if you have /usr/lib/libfoo.a, then
cmake will add -Wl,-static -lfoo around foo. So, if CMake is given a
full path to a shared library it will add -Wl,-dyanmic around it.
-Bill
More information about the CMake
mailing list