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...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Interop (show other bugs)
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-31 15:39 UTC by Hin-Tak Leung
Modified: 2017-09-01 22:11 UTC (History)
2 users (show)

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


Attachments

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:
 @loader_path/libpixman-1.0.dylib
   Referenced from: 
 /var/folders/1p/gc7gfjfj5vx2t8smh_bx65h40000gn/T/mono-bundle-tZ6AeJ/libcairo.2.dylib
   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 
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.

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.