3.7.2. Prefixing the Library Major soname with the Software Collection Name
When using libraries included in the Software Collection, always remember that a library with the same major soname can already be available on the system as a part of the base system installation. It is thus important not to forget to use the
scl enable
command when building an application against a library included in the Software Collection. Failing to do so may result in the application being executed in an incorrect environment, linked against the incorrect system version of the library.
Warning
Keep in mind that executing your application in an incorrect environment (for example in the system environment instead of the Software Collection environment) as well as linking your application against an incorrect library can lead to undesired behavior of your application, including unexpected termination and data loss.
To ensure that your application is not linked against an incorrect library even if the
LD_LIBRARY_PATH
environment variable has not been set properly, change the major soname of the library included in the Software Collection. The recommended way to change the major soname is to prefix the major soname version number with the Software Collection name.
Below is an example of the MySQL client library with the
mysql55-
prefix:
$
rpm -ql mysql55-mysql-libs | grep 'lib.*so'
/opt/provider/mysql55/root/usr/lib64/mysql/libmysqlclient.so.mysql55-18 /opt/provider/mysql55/root/usr/lib64/mysql/libmysqlclient.so.mysql55-18.0.0
On the same system, the system version of the MySQL client library is listed below:
$ rpm -ql mysql-libs | grep 'lib.*so'
/usr/lib64/mysql/libmysqlclient.so.18
/usr/lib64/mysql/libmysqlclient.so.18.0.0
The
rpmbuild
utility generates an automatic Provides
tag for packages that include a versioned shared library. If you do not prefix the soname as described above, then an example of the Provides
in case of the mysql package is libmysqlclient.so.18()(64bit)
. With this Provides
, RPM can choose the incorrect RPM package, resulting in the application missing the requirement.
If you prefix the soname as described above, then an example of the generated
Provides
in case of mysql is libmysqlclient.so.mysql55-18()(64bit)
. With this Provides
, RPM chooses the correct RPM dependencies and the application's requirements are satisfied.
In general, unless absolutely necessary, Software Collection packages should not provide any symbols that are already provided by packages from the base system installation. One exception to that rule is when you want to use the symbols in the packages from the base system installation.