Bug 21648 - Dlopen() is apparently looking at wrong dylib version # ("compatibility version" not the "library version" like it should)
Summary: Dlopen() is apparently looking at wrong dylib version # ("compatibility versi...
Status: RESOLVED UPSTREAM
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other ()
Version: 0.9.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2014-07-28 17:20 UTC by troy-dawson
Modified: 2014-07-29 12:09 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
dylib settings in Xcode, showing the two different version settings (310.66 KB, image/png)
2014-07-28 17:20 UTC, troy-dawson
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description troy-dawson 2014-07-28 17:20:55 UTC
Created attachment 7511 [details]
dylib settings in Xcode, showing the two different version settings

This bug is with the latest MonoMac, not Xamarin.Mac, maybe it's fixed with Xamarin. . .

At runtime, I had a linked dylib referencing another dylib (SDL2_image linking SDL2) and failing -- 

running my .exe with mono with debug I got this output from the console:

Mono: DllImport error loading library '/Users/troy/Projects/FNATest/FNATest/bin/Debug/libSDL2_image-2.0.0.dylib': 'dlopen(/Users/troy/Projects/FNATest/FNATest/bin/Debug/libSDL2_image-2.0.0.dylib, 9): Library not loaded: /Users/troy/Frameworks/SDL2.framework/SDL2
  Referenced from: /Users/troy/Projects/FNATest/FNATest/bin/Debug/libSDL2_image-2.0.0.dylib
  Reason: Incompatible library version: libSDL2_image-2.0.0.dylib requires version 3.0.0 or later, but SDL2 provides version 0.0.0'

(A blank compatibility version in the SDL framework Xcode settings maps to 0.0.0)

Rebuilding /Users/troy/Frameworks/SDL2.framework/SDL2 with compatibility version set to 1.2.3 would change the output to:

 Reason: Incompatible library version: libSDL2_image-2.0.0.dylib requires version 3.0.0 or later, but SDL2 provides version 1.2.3'

which gave me the clue about what the problem here was.

Rebuilding SDL with a ompatibility version of 3.1, fixed the problem, but Mono should look at the "version" proper, not the "compatibility version" for determining a legal link, since the compatibility version specifies the minimum API level supported, not the maximum.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-07-29 03:31:35 UTC
The error message isn't from Mono itself, it comes from the native dlopen method (mono just prints the output of dlerror after dlopen failed).

This means the bug is in OSX and that should easily be able to reproduce it by writing a small C program that just dlopens your library.

If that's not the case, then please attach a test case we can use to reproduce the bug.
Comment 2 troy-dawson 2014-07-29 12:09:33 UTC
Oops, I see the SDL_image.dylib was built against SDL.dylib of minimum version 3.0.0.

dlopen()'s error message is cryptic, the versioning system is convoluted, and OS X docs are unclear, but that's not Mono's fault.