[CMake] automatic library dependencies causing problems

Brad King brad.king at kitware.com
Fri Feb 4 08:44:41 EST 2005


Clinton Stimpson wrote:
> I've found a solution for my problem.
> 
> When I build libD.so, I add "-all" to export symbols from the static 
> libraries E-H.
> Then libA.so and libB.so won't get their own copies of libs E-H, and the 
> linker will emit a warning saying that they were ignored.
> 
>  IF(CMAKE_SYSTEM MATCHES "IRIX")
>    SET_TARGET_PROPERTIES(D PROPERTIES LINK_FLAGS -all)
>  ENDIF(CMAKE_SYSTEM MATCHES "IRIX")

You should be aware that having a shared library depend on a static 
library is potentially problematic on all platforms.  If the shared 
library really needs symbols from the static library then it should 
either have them built in or the static library should be made shared. 
Otherwise nothing can load the shared library without linking to the 
static library first.  The only alternative is to put a copy of the 
static library in the shared library, which is what was happening to 
you.  If the shared library doesn't need symbols from the static library 
then it shouldn't link to it at all.

-Brad


More information about the CMake mailing list