[CMake] How to create a static library out of other static libraries in CMAKE ?

Andreas Pakulat apaku at gmx.de
Mon Jun 15 06:03:32 EDT 2009


On 14.06.09 20:50:22, Xiangyun Kong wrote:
> 
> Thanks. When I link the mylib with other objects to form a
> dynamic library, I got a lot of undefined symbols.

Thats normal, if you link to static libraries only the symbols that are
used in your target are fetched from the static libs. So lets say you have
libA which is a static library exposing the symbols foo and bar. Then you
have libB which is also a static library and it uses foo from libA. If you
now link libB to libA, then the bar symbol will be lost. If you try to link
libB into another target which needs the bar symbol you'll get undefined
references. You need to specifiy libA as well when linking the shared lib,
or you need to make sure that libB uses all symbols from libA.

Andreas

-- 
Caution: breathing may be hazardous to your health.


More information about the CMake mailing list