Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 405486 - C client library should be versioned
Summary: C client library should be versioned
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Paho (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ian Craggs CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 405487 405837
  Show dependency tree
 
Reported: 2013-04-11 11:54 EDT by Roger Light CLA
Modified: 2016-02-05 11:15 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Light CLA 2013-04-11 11:54:47 EDT
Shared libraries on Linux and similar systems are expected to have a version number, e.g. libmqttv3c.so.1 rather than libmqttv3c.so. If binary incompatible changes are made to the library the first major number is incremented, libmqttv3c.so.2.0.0. Strictly speaking the following is true, but not always implemented. If a new version is released that is compatible, the second version number is incremented libmqttv3c.so.1.1.0. Minor bugfixes are the final number.

When the library is installed, a symbolic link is made for libmqttv3c.so.1 -> libmqttv3c.so.1.0.0 so that applications link against libmqttv3c.so.1 rather than a specific version and bugfix release.

More information is available here for example: http://www.debian.org/doc/debian-policy/ch-sharedlibs.html

In addition to the naming, during the linker step the soname of the library should be set. This can be done with the "-Wl,-soname,libmqttv3c.so.1" option to gcc.
Comment 1 Ian Craggs CLA 2013-04-11 12:26:08 EDT
Is the policy the same for all Linux distributions?  We don't have an installation process at the moment, so I'm unclear at what point the symbolic link would be made.

I would add that I don't intend there to be binary incompatible changes at any point, but accept the precaution and convention of versioning.
Comment 2 Roger Light CLA 2013-04-11 16:02:58 EDT
All the major distros do it like this as far as I know. It's asking for trouble to do it any other way to be honest. If you don't have versioned libraries then it's not possible to have multiple incompatible versions installed at once.

I'd have installation targets with something like this:

install -s libmqttv3c.so.1.0.0 ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmqttv3c.so.1
ln -sf libmqttv3c.so.1.0.0 ${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmqttv3c.so.1

I agree about the binary compatibility, but there's essentially no downside to having the versioned library once you've got the build scripts sorted. If there is an ABI break it's trivial to change the build scripts as well.
Comment 3 Andy Piper CLA 2013-04-11 19:17:38 EDT
(In reply to comment #1)
> Is the policy the same for all Linux distributions?  We don't have an
> installation process at the moment, so I'm unclear at what point the
> symbolic link would be made.

Usually that's done automatically by the package manager e.g. dpkg or rpm in the case of Debian and RH-based distros, respectively.

We could certainly use an RPM .spec and apt config for the Paho C client.
Comment 4 Andy Piper CLA 2013-04-15 06:42:41 EDT
Assigning to MQTT-C component
Comment 5 Ian Craggs CLA 2013-10-30 10:01:07 EDT
I've created a new Makefile in the root of the C project which versions the libraries according to this document http://l4u-00.jinr.ru/usoft/WWW/HOWTO/GCC-HOWTO-6.html on Linux.

A version number which has just two components, major and minor, seems sufficient to me. Unless anyone wants to suggest otherwise.

Hmm, I've used cp rather than the install command.  Benefits to using install?  Is there an uninstall?

I'm planning to add a MacOS section to the Makefile, which can do the same or similar, and leave the operating system it at that for now (a Visual Studio project and Ant builds for Windows).
Comment 6 Roger Light CLA 2013-10-30 10:23:10 EDT
Benefits of install:

You can create directories and copy the file in one operation using -D.
You can set user/group ownership and permissions.
You can strip debug information.

Even if you aren't doing those it's the defacto standard way of copying compiled files to the system. I don't think it's hugely important. Personally I make all commands into variables so they can be changed easily if needed.


One thing you should add is a .PHONY line for the targets that don't produce output, like all, mkdir, clean, ...
Comment 7 Ian Craggs CLA 2013-10-31 11:04:07 EDT
I've updated the Makefile in the master branch.

1) install used instead of cp
2) install-strip target added
3) MQTTVersion now built and installed
4) .PHONY target added

I'm not overly happy about the list of install and rm commands in the install and uninstall targets, but the alternatives seemed just as complicated, unless you know better, Roger.