[cmake-developers] New no-soname-option topic for e.g. Android

Brad King brad.king at kitware.com
Wed May 28 14:15:29 EDT 2014


On 05/28/2014 12:17 PM, Nils Gladitz wrote:
> In case you drop "-Wl,-soname" entirely ... how do you work around the 
> issue of the linker using paths rather than names in NEEDED entries?
> Or does the issue not exist on OpenBSD?

This is an important issue.

CMake generates link command lines that refer to library files by path
rather than asking the linker to search with a -lfoo option.  This
approach ensures the expected library file is linked.  If the library
file has no DT_SONAME then some linkers put the path in DT_NEEDED.
For example, compare three commands for linking to a /path/to/libfoo.so
file that has no DT_SONAME:

 ====================================  ==============================
 Command Line                          Result
 ====================================  ==============================
 cc A.c -o A -L/path/to -lfoo          DT_NEEDED = libfoo.so
 cc B.c -o B /path/to/libfoo.so        DT_NEEDED = /path/to/libfoo.so
 cd /path && cc C.c -o C to/libfoo.so  DT_NEEDED = to/libfoo.so
 ====================================  ==============================

Therefore linking by path to a library requires that the library
have a DT_SONAME, or that the linker be modified to do something
else for DT_NEEDED.

-Brad




More information about the cmake-developers mailing list