TipsAndTricks/PackagingNonversionedLibrary: Difference between revisions
RossBurton (talk | contribs) |
RossBurton (talk | contribs) m (RossBurton moved page TipsAndTrick/PackagingNonversionedLibrary to TipsAndTricks/PackagingNonversionedLibrary) |
(No difference)
|
Revision as of 16:36, 28 July 2016
How to Package an Unversioned Library
First some background: in general libraries in Linux systems are versioned so that it's possible to have multiple versions of the same library installed, to ease upgrades or support older software. In versioned libraries the actual library binary is for example called libfoo.so.1.2, and then there will be a libfoo.so.1 symbolic link to libfoo.so.1.2, and finally a libfoo.so symbolic link to libfoo.so.1.2. When linking a binary against a library then you typically just tell it the unversioned file name (for example, -lfoo to the linker) but the linker will follow the symbolic links and actually link against the fully-versioned filename. The unversioned symbolic link is only used at development time, so in OpenEmbedded (as with all other Linux distros) gets packaged along with the headers in development package ${PN}-dev. As versioned libraries are far more common than unversioned libraries, the default packaging rules assume versioned libraries.
However this means that packaging an unversioned library isn't trivial, as by default libfoo.so will get packaged into PN-dev (triggerring a QA warning that a non-symlink library is in PN-dev), and binaries in the same recipe will link to the library in PN-dev (and trigger more QA warnings). To solve this the unversioned library needs to be packaged into ${PN} where it belongs, so lets have an abridged look at the default FILES variables in bitbake.conf:
SOLIBS = ".so.*" SOLIBSDEV = ".so" FILES_${PN} = "... ${libdir}/lib*${SOLIBS} ..." FILES_SOLIBSDEV ?= "... ${libdir}/lib*${SOLIBSDEV} ..." FILES_${PN}-dev = "... ${FILES_SOLIBSDEV} ..."
SOLIBS defines a pattern that matches real shared object libraries, and SOLIBSDEV matches the development form (unversioned symlinks, typically). These are then used in FILES_${PN} and FILES_${PN}-dev which puts the real libraries into PN and the unversioned symbolic link into PN-dev. To package unversioned libraries, this needs to be modified as follows in the recipe:
SOLIBS = ".so" FILES_SOLIBSDEV = ""
This says that .so is the real library, and unsets FILES_SOLIBSDEV so that no libraries get packaged into PN-dev. This is required because PN-dev collects files before PN, so FILES_PN-dev must not collect any of the files.