-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS dylib minor version numbers differ between cmake and autotools builds #622
Comments
Can you elaborate what kind of software are you talking about? |
I gave the example of mspdebug because it was one of the software programs in MacPorts that depends on hidapi and that has few other dependencies, but any software linking with the library would be affected.
That's a different matter. I'm a developer with MacPorts. The inciting incident that caused me to look into hidapi was the report to us five months ago that hidapi_darwin.h was not installed and my reencountering that issue yesterday. My investigation led me to discover that the cause was the difference in build system, so I filed #620. I discovered the recommendation to switch to cmake, which prompted me to investigate the viability of doing so, which led me to discover the dylib versioning difference and the inability (without workarounds, which we can use, with a little difficulty) to build both shared and static libraries at the same time. |
One difficulty in fixing the library versioning problem is that in the cmake build system you are using your project's version number as the library version number: Lines 18 to 27 in c19ae12
These should not be coupled. There should be separate variables for the components of your library version number in the cmake build system as there already are in the autotools build system: Lines 8 to 15 in c19ae12
|
TL;DR; version of the library built with CMake will remain unchanged by default.
That is true if the project contains multiple components possibly of different versions or if the library has its own (different) versioning stategy.
Most probably not a variable. The version of the library is not something that user should deside at build time.
As you may see from the blame - no one ever bothered to manage the library version with Autotools. The version always was In other words - I find current behavior of the Autotools to be a bug (e.g. #392) which is "fixed" in CMake. But I totally understand the pain this may cause in scenarios like MacPorts when you upgrade only a single library w/o recompilation of all others. Specifically for cases like this one, I think it should suffise adding a macOS-specific CMake option @ryandesign is there anything else stopping MacPorts from switching to CMake build system for HIDAPI? |
@ryandesign please let me know what you think. |
When building hidapi 0.14.0 on macOS, the dynamic library's minor version information is different depending on whether cmake or autotools was used for the build.
With autotools:
With cmake:
With autotools the library's major version is 0 and its minor version is 1.0.0 (compatible back to minor version 1.0.0) whereas with cmake the library's major version is still 0 but its minor version has regressed to 0.14.0 (compatible back to minor version 0.0.0).
This is bad because the major and minor library version that was available at compile time is baked into each binary that uses the library. For example, here's a program that was built with hidapi-compiled-with-autotools:
If I then replace libhidapi with one compiled with cmake, the program will not run*:
This means that if a user wants to switch from hidapi compiled with autotools to hidapi compiled with cmake, they have to recompile all their software that links with libhidapi. This is a barrier to getting people to switch from autotools to cmake, as I believe you want us to do.
You have to be very careful to match your previous library version numbering scheme when switching to a different build system. libtool has a very special way of defining library versions that you have to follow. What's not explained there, because I guess they considered it an implementation detail that you didn't need to know about if you never stopped using libtool, is that library minor versions on macOS are 1.0.0 higher than on other operating systems because when Mac OS X was first introduced it could not handle library minor versions less than 1.0.0 but there was existing Unix software using libtool that specified library versions less than 1.0.0. macOS has been able to handle library minor versions less than 1.0.0 for a long time now but of course libtool can never remove that workaround or else projects' library minor versions would decrease when they updated libtool.
*What I did not realize until I researched it for this bug report is that Apple removed these library version checks completely in macOS 12, and in macOS 10.14(?) through macOS 11, it only runs the checks if the library was built for a macOS version earlier than 10.14. But since I'm sure you want your software to work on the widest range of systems possible, you should continue to follow the original spirit of the library minor version numbers by never letting them decrease (for any given major library version number; when the major library version number increases, of course the library minor version number can reset).
The text was updated successfully, but these errors were encountered: