Bug 59154 - runtime can't load secondary-dependent library from newly unpacked temp directory
Summary: runtime can't load secondary-dependent library from newly unpacked temp direc...
Alias: None
Product: Runtime
Classification: Mono
Component: Interop ()
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-08-31 15:39 UTC by Hin-Tak Leung
Modified: 2017-09-01 22:11 UTC (History)
2 users (show)

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

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 GitHub or Developer Community 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:

Description Hin-Tak Leung 2017-08-31 15:39:40 UTC
I have played with the new "mkbundle --simple ... --library ..." to bundle native libraries. While libraries with
simple dependencies (i.e. not depending on anything else other than system libraries) are fine, the new mechanism can't cope with secondary dependencies.

I tried changing the dependencies to @loader_path and there is what it says:

dlopen(/var/folders/1p/gc7gfjfj5vx2t8smh_bx65h40000gn/T/mono-bundle-tZ6AeJ/libcairo.2.dylib, 9): Library not loaded:
   Referenced from: 
   Reason: image not found

libcairo.2.dylib is as from mono 5.2.0 but modified to look like this (note the @loader_path entries):

$ otool -L libs/libcairo.2.dylib 
	/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/libcairo.2.dylib (compatibility version 11203.0.0, current version 11203.14.0)
	@loader_path/libpixman-1.0.dylib (compatibility version 31.0.0, current version 31.0.0)
	@loader_path/libfontconfig.1.dylib (compatibility version 8.0.0, current version 8.2.0)
	@loader_path/libfreetype.6.dylib (compatibility version 17.0.0, current version 17.2.0)
	@loader_path/libpng14.14.dylib (compatibility version 27.0.0, current version 27.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.14.0)
Comment 1 Hin-Tak Leung 2017-08-31 20:13:59 UTC
Oh, I realize one subtlety - it is saving and dl_opening one at a time, according to the code https://github.com/mono/mono/blob/master/mono/mini/main.c Line 274. Therefore the --library arguments needs to be listed in dependency order.

I'll give it a try...
Comment 2 Hin-Tak Leung 2017-09-01 10:22:22 UTC
Specifying the library list in dependency order does allow the result to launch.

This needs to be added to the documentation/help :-).
Comment 3 Hin-Tak Leung 2017-09-01 22:11:03 UTC
I created https://github.com/mono/mono/pull/5495 to update the man page.

For the record, my initial mistake was doing it in alphabetical order (c before p).

It should not be an issue for it to be merged, so I am closing this now.