Bug 36884 - MKBundled Mono Exe checking for Dependency in Library Folder
Summary: MKBundled Mono Exe checking for Dependency in Library Folder
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Runtime ()
Version: Master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-12-11 10:33 UTC by cool_rainbow
Modified: 2016-06-11 06:29 UTC (History)
2 users (show)

Tags:
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 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 ANSWERED

Description cool_rainbow 2015-12-11 10:33:18 UTC
I have bundled an Exe with Mono in Mac using 

    export AS="as -arch i386"
    export CC="cc -arch i386 -framework CoreFoundation -lobjc -liconv"
    export PATH=/Library/Frameworks/Mono.framework/Versions/4.0.3/bin:$PATH
    mkbundle -- static myapp.exe  MonoMac.dll --deps -o myapp

It successfully produces the native application myapp.
I copied the lib directory from mono folder and pasted it on desktop because the app uses **GTK** for User Interface.

I'm trying to launch the application using  the following ***script.sh*** 

    VAR=`pwd`
    export DYLD_FALLBACK_LIBRARY_PATH="$VAR/lib:/usr/lib"
    ./myapp
The  app successfully launches provided that Mono is installed in Library folder*** if i remove Mono.Framework from the Library Folder i get the following error

http://i.stack.imgur.com/XXcoo.png

My question is isn't the static Flag used to include Mono Runtime with the Exe and produce a non dependent Native code(Except GTK for which i have set the DYLIB Path),Why is it looking for Mono in the Library Folder?
Comment 1 Chris Hamons 2015-12-14 20:50:13 UTC
So a few things.

- You are using MonoMac.dll, so this isn't a Xamarin.Mac bug. 
- You might get more information on where mono is looking for libraries with MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm as prefixes when launching your application as detailed here (http://www.mono-project.com/docs/advanced/runtime/logging-runtime-events/).
- Bug reports aren't for questions. Please see the forums (https://forums.xamarin.com/categories/mac) for a more appropriate place for questions.
Comment 2 cool_rainbow 2015-12-15 04:41:27 UTC
Im not using Monomac.dll alone.Im just using it for showing the NSOpenPanel so that the file dialog has a native look and feel on OSX,rather than the alien GTK Look and feel.

Im using your IDE Xamarin Studio and i intent to use GTK UI for it.If i want to distribute the bundled Mono Runtime  i know that i need to purchase Xamarin.Mac.

So this is indeed a Bug.I tried setting the DLLMAPs too.
Comment 3 Chris Hamons 2015-12-15 14:59:29 UTC
Just for clarification, as I indicated in my last response, MonoMac.dll != XamMac.dll or Xamarin.Mac.dll. This bug was filed against Xamarin.Mac, so I wanted to clarify that you filed it against the wrong product.

Moving on from that, bug reports aren't the best location for questions. I do not believe this report currently has enough information to say "Product X has a bug" as much as "I'm trying to use X and it is not working as expected."

I would suggest using MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm to track down where mono is trying to load the library in question, and posting on the forums if you need help.

If and when you track down the source of the bug, feel free to open a new bug with a detailed description of the problem or a example that reproduces the flaw.
Comment 4 cool_rainbow 2015-12-15 16:47:42 UTC
Okay.I get your point.But this is indeed a bug with mkbundle or the mono runtime.The static flag bundles mono with the exe,why does the bundled mono look for the libraries folder? So this is a Bug i suggest you move this to the proper section.Xamarin IDE itself is full of Bugs,now i have to deal with this too.
Comment 5 cool_rainbow 2015-12-15 16:48:51 UTC
Plus no one answers the questions on SO or the Mailing List.Mono and GTK seems abandoned.I dont know why i should pay for Xamarin.Mac if this is the Case.
Comment 6 cool_rainbow 2015-12-16 16:44:16 UTC
This is indeed a Bug.What is the point is using MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm. I mean from where im i supposed to use that.The system to which the app should be installed does not have mono.Mono should be bundled since im using the --static flag with mkbundle.I tried modifying the dllmap.. nothing helps.Here is a related thread
 
https://bugzilla.redhat.com/show_bug.cgi?id=692784


I suggest you take some interest in sorting out this issue otherwise Mono+GTK will go down the drain.You people are just so busy to close bug reports without even trying to understand the issue.
Comment 7 Chris Hamons 2015-12-16 20:43:19 UTC
Alright, I see why you are frustrated, and I'm sorry the command line tooling isn't working as expected. However, because this is not a Xamarin.Mac issue, we need to get your issue to the correct place where it can be taken care of. There are several options: we can move this bug to MonoMac, but since MonoMac and GTK# are community supported projects, it may be a very long time until you see any response. I recommend filing a post on our forums for community support instead - https://forums.xamarin.com/categories/mac - where more members of the community will see it. 

If you do end up filing this as a bug or community issue, you'll first need to dig into how mono is loading the libraries in question, using the MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm method I suggested. Once you know where mono is trying to load the library in question, you should have enough info for others to go on. 

If you have a Xamarin license with access to Xamarin support or an account manager, they may be able to re-evaluate the issue for you. It's worth reaching out to them even if you haven't purchased Xamarin.Mac.
Comment 8 Hin-Tak Leung 2016-06-11 06:29:34 UTC
You need to use the ' --config config ' option of mkbundle, to make a copy of '/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/config' and remove or edit the content for the location of where glib, etc could be found.

If you watch the mkbundle's output log, you will find that '/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/config' is included in the generated bundle. ' --config config '  overrides that, and allows you to specify where glib, etc are in the client's machine. The client still need to have those, but you could put a copy of those in your `pwd` anyway.

The mono people did give you an option, you just need to read mkbundle's doc carefully. This is not a bug, just poorly documented.

$ mkbundle --help
...
    --config F          Bundle system config file `F'
...



FYI, I built the microsoft font validator for mac os this way. 
(
source https://github.com/HinTak/Font-Validator

binaries - *.dmg for macs - 
https://sourceforge.net/projects/hp-pxl-jetready/files/Microsoft%20Font%20Validator/ )