[CMake] static library linking

Steven Van Ingelgem steven at vaningelgem.be
Sun Jun 15 13:28:25 EDT 2008


Hi Alan,


I don't know why, but if I take the build command from cmake, and I insert
the static libraries in there, it works all right. So somehow it's reverting
itself to some other version of the static and/or dynamic libraries.

The entire point of me reporting this in fact is that in cmake cvs this
should have been resolved... Meaning that if I say in my CMakeLists file to
link against the static library, it should just keep that link... Not try to
be smart and change it ;-).


Greetings,
Steven

2008/6/15 Alan W. Irwin <irwin at beluga.phys.uvic.ca>:

> On 2008-06-15 11:47+0200 Steven Van Ingelgem wrote:
>
>  A small example (and verified on a clean SUSE installation):
>>
>> ====================
>> PROJECT(test)
>>
>> cmake_policy(SET CMP0003 NEW)
>>
>> ADD_EXECUTABLE(
>>  test
>>  main.cpp
>> )
>> TARGET_LINK_LIBRARIES(
>>  test
>>  /usr/lib/libpthread.a
>>  /usr/lib/librt.a
>>  /usr/lib/libc.a
>> )
>> ====================
>>
>> ==> this won't set the .a's in the commandline as it should do, but rather
>> link it via -Wl,-Bstatic...
>>
>>
>> And I really need those static links, because no single other library on
>> the
>> system exports the required symbols, not even the shared ones.
>>
>
> Out of curiosity, why doesn't -Wl,-Bstatic -lpthread do exactly what you
> want? According to the Linux ld man page, -Bstatic means "do not link
> against shared libraries" so shouldn't that have the identical result as
> specifying /usr/lib/libpthread.a?
>
> To double-check what is happening with the linking, use "ldd -r" to list
> all the shared (but not static) libraries being linked to by test and to
> show any symbols which are not resolved by the link.  You can also use
> nm to look for unresolved symbols.
>
> Alan
> __________________________
> Alan W. Irwin
>
> Astronomical research affiliation with Department of Physics and Astronomy,
> University of Victoria (astrowww.phys.uvic.ca).
>
> Programming affiliations with the FreeEOS equation-of-state implementation
> for stellar interiors (freeeos.sf.net); PLplot scientific plotting
> software
> package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
> Linux Links project (loll.sf.net); and the Linux Brochure Project
> (lbproject.sf.net).
> __________________________
>
> Linux-powered Science
> __________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080615/5d896c66/attachment.htm>


More information about the CMake mailing list