Hi Denis,

There are definitely cases where you do want to create a statically
linked executable; for example when running on a massively parallel
diskless system -- you don't want thousands of compute nodes to load a
shared library over some NFS link.

Anyway, the real problem with find_library() is, when you have a shared
library installed, but not the associated static library. In that case,
the linker will choke while creating a statically linked executable,
because it cannot find the library it needs.

I guess the only way to solve this is to manually set
CMAKE_FIND_LIBRARY_SUFFIXES, like FindBoost.cmake does. I wish there
were a more generic, platform-independent way to do this. Maybe worth a
feature request?

Best regards,
Marcel Loose.


On Fri, 2009-05-08 at 06:33 -0700, Denis Scherbakov wrote:
> 
> > 1) Is there a generic platform- and compiler-independent
> > way to specify
> > that you want to create a statically linked executable?
> 
> find /usr/share/cmake -type f | grep -E '\.cmake$' | xargs grep -i -n -H 
> '\-static'
> 
> No matches == there is no cross-platform way to specify that you want static 
> exectuable.
> 
> I think this is a bug, but since, we are talking about static executables, 
> you may want to read http://people.redhat.com/drepper/no_static_linking.html
> 
> In general, linking statically is a very bad idea.
> Moreover, if your code is not GPL, you're not allowed to link against 
> libc/libgcc statically. It is direct GPL violation.
>  
> > 2) How can I persuade find_library() to only search for
> > static
> > libraries?
> 
> You don't need to. -static option for gcc will make the trick and gcc will 
> automatically pick *.a instead of *.so, if it exists.
> 
> 
> 
>       

_______________________________________________
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

Reply via email to