[CMake] linking static libraries

Andreas Pakulat apaku at gmx.de
Fri May 30 19:07:33 EDT 2008


On 30.05.08 17:06:28, Eric Torstenson wrote:
> Hi All,
>
> I'm running an application that uses a handful of semi-standard  
> libraries (freetype, libpng, zlib). Before I switched over to cmake, I  
> was linking to the static version of those libraries, and my app seemed  
> to run fine on machines as long as it was a recent version of linux.
>
> However, since I've switched to cmake, I've begun getting complaints  
> that the binaries are no longer compatible. They are getting floating  
> point exceptions just running it without arguments (which just prints  
> out the typical help stuff).
>
> The most likely culprit is an .so file that isn't quite right.

Thats called binary compatiblity problems and happens when an
application changes certain things in its API, which might be source
compatible, but produces different symbols in the library. 

> I've gone over the manual, but I don't see a way to tell  
> TARGET_LINK_LIBRARIES to prefer static over dynamic? I really can't ask  
> these folks to recompile the software, since we are talking about 5 or 6  
> dependancies (including cmake itself, since I'm using 2.7)

Use STRING REPLACE on the full-path libraries and replace .so with .a,
that should work.

One of the major downsides of the static linking is that you are
responsible for making sure the libraries you link to statically don't
have any known security issues or bugs and if needed upgrade them and
rebuild your app against them.

Andreas

-- 
If your life was a horse, you'd have to shoot it.


More information about the CMake mailing list