[CMake] CMAKE uses wrong symlink to so

Michael Wild themiwi at gmail.com
Thu Dec 30 07:23:52 EST 2010


On 12/30/2010 12:28 AM, j s wrote:
> I specified the full name to an so in CMAKE 2.8.1.  Unfortunately it links
> against the versioned so name,
> libpython2.6.so.1.0
> 
> instead of the exact name I specified.
> /usr/lib/libpython2.6.so
> 
> SET (PYTHON_ARCHIVE /usr/lib/libpython2.6.so)
> TARGET_LINK_LIBRARIES (myapp  parser engine ${PYTHON_ARCHIVE}
> ${OPENSSL_ARCHIVE})
> 
> Is there any way to tell cmake to do the right thing in Linux?  For some
> strange reason using -l on the link line, and doesn't even use the
> corresponding -L to the path I specify.
>   -lpython2.6
> 
> 
> Regards,
> 
> Juan

There's nothing CMake can do about this, this is the linker getting in
your way. E.g. on my Ubuntu, /usr/lib/libpython2.6.so is a symlink to
/usr/lib/libpython2.6.so.1 which itself is a symlink to
/usr/lib/libpython2.6.so.1.0. The linker recursively resolves all
symlinks during the linking, and CMake can't do anything about it. You
could pass the full path to the /usr/lib/libpython2.6.so symlink instead
of -lpython2.6 and you would still get the same result.

Actually, this is considered to be a feature. This way, newly compiled
programs will always link against the "current" version (the one pointed
to by the symlink-chain), while old programs can still use  older
versions of the library without requiring to be recompiled.

Michael




More information about the CMake mailing list