On 28.05.2014 20:15, Brad King wrote:
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


I was curious and did a VM install of OpenBSD (5.5) to have a peek.
Most of this will be obvious to OpenBSD users but this was all rather new to me :p ...

There is a /usr/lib/libz.so.5.0
There is no /usr/lib/libz.so
-lz links to /usr/lib/libz.so.5.0 nonetheless
The library has no SONAME.
None of the libraries under /usr/lib in the default install seem to have an SONAME though I am able to create libraries with SONAME manually.

The linker does embed paths to libraries in NEEDED entries like it would on e.g. GNU/Linux.

This seems to imply that convention on OpenBSD is indeed to not have any SONAMEs at all.

Given that the topic might have one valid use case after all?

Nils
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to