[CMake] FindX11 and FindLibXml2: different behaviors when using static/dynamic libraries

Philip Lowman philip at yhbt.com
Wed Nov 11 23:55:07 EST 2009


These seem like bugs to me.  I'm pretty sure you're going to have similar
luck across many find modules in CMake, however.  I don't think static
linking is that widely tested, unfortunately.

For libxml2's dependency on pthread you should be able to use FindThreads or
FindPthreads.  I'm not sure about xcb_get_request_sent, I would try libxcb?

Also, complicating this problem are questions about "optional"
dependencies.  CMake find modules don't know if libxml2 was built with or
without pthreads support, for example.

I think if you're planning on doing static linking, you're probably going to
have to resolve dependencies manually in a lot of cases at least with the
way things currently are done.


On Tue, Nov 10, 2009 at 5:29 PM, <olivier.pierard at cenaero.be> wrote:

>
> Dear all,
>
> For the compilation of my project, I want to provide a static or dynamic
> linked final executable (e.g.: linking preferentially with .a or .so
> libraries on Linux).  For this, I set up a cache variable which enables to
> modify CMAKE_FIND_LIBRARY_SUFFIXES (".a;.so" or ".so;.a").  By the way, I
> don't know if that's the good way ?
>
> In a find module that I wrote myself, I call FindX11.cmake and
> FindXml2.cmake (provided by my distribution - suse 10.3).  Everything works
> perfectly for dynamically linked libraries but fails at final link when
> using static link.  Among the numerous errors, I can find things like
> -
>
> /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/libX11.a(xcb_lock.o):
> In function `_XPutXCBBuffer':
> (.text+0xd9): undefined reference to `xcb_get_request_sent'
> -
>
> /usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/libxml2.a(threads.o):
> In function `xmlInitThreads':
> (.text+0x3a): undefined reference to `pthread_key_create'
>
> I guess it means that a static library is missing in the final link.  But
> such dependencies shouldn't be taken by the corresponding find Module ?  In
> that case, could you provide me a reference site where I can find reliable
> find modules.  Or Am I missing something in my own find module ?
>
> Thanks for your help !
>
> Olivier
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091111/28f7a1c4/attachment.htm>


More information about the CMake mailing list