[Mono-list] New: cross-compiling with mkbundle

Miguel de Icaza miguel at microsoft.com
Wed Aug 10 03:06:43 UTC 2016


Hello,

That command line is using the old mkbundle system, not the new one.

That said, the error is likely the same, can you try using MONO_PATH to direct the loader?

From: Dave Curylo <dacurylo at gmail.com> on behalf of David Curylo <curylod at asme.org>
Date: Tuesday, August 9, 2016 at 5:42 PM
To: Miguel de Icaza <miguel at microsoft.com>
Cc: "mono-list at lists.dot.net" <mono-list at lists.dot.net>
Subject: Re: [Mono-list] New: cross-compiling with mkbundle

Miguel,

Thanks for this, better cross-compiling support is huge given I don’t need to have a ton of CI agents handling it.  However, something seems to break for me when using the mkbundle that ships with 4.4.2.

mkbundle --deps --static -o myApp MyApp.exe *.dll

fails with an exception looking for an old version of a .dll, in my case Npgsql:

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Npgsql, Version=2.2.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its dependencies
File name: 'Npgsql, Version=2.2.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'
  at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) <0x19f78c0 + 0x000b0> in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string,System.Security.Policy.Evidence,bool)
  at System.Reflection.Assembly.ReflectionOnlyLoad (System.String assemblyString) <0x1a72eb0 + 0x00038> in <filename unknown>:0
  at IKVM.Reflection.Universe.DefaultResolver (System.String refname, Boolean throwOnError) <0x6e7890 + 0x00057> in <filename unknown>:0
  at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, Boolean throwOnError) <0x6e6f68 + 0x0006f> in <filename unknown>:0
  at IKVM.Reflection.Universe.Load (System.String refname) <0x6e6f30 + 0x00027> in <filename unknown>:0
  at MakeBundle.QueueAssembly (System.Collections.Generic.List`1 files, System.String codebase) <0x7b44b0 + 0x001ab> in <filename unknown>:0
No problems bundling with mkbundle from 4.2.3 - it runs there in CI all the time.  Did something in this new version change how assemblies are located?

Thanks,
Dave

On Aug 9, 2016, at 5:35 PM, Miguel de Icaza via Mono-list <mono-list at lists.dot.net<mailto:mono-list at lists.dot.net>> wrote:


From: Miguel de Icaza <miguel at microsoft.com<mailto:miguel at microsoft.com>>
Subject: New: cross-compiling with mkbundle
Date: August 9, 2016 at 2:02:11 PM EDT
To: "mono-list at lists.dot.net<mailto:mono-list at lists.dot.net>" <mono-list at lists.dot.net<mailto:mono-list at lists.dot.net>>


Hello folks,

The new mkbundle tool in Mono no longer requires an installed compiler, and you can use it to cross compile.

Would love to get some feedback from you guys.

First, get a list of all cross-platform targets available, like this:

mkbundle –list-targets

Then, find out which version of Mono you have on your system:

mono –version

Use this to pick the right version and fetch it, for example, to cross compile to Linux/64 from a Mac do:

mkbundle –fetch-target 4.4.2-linux-libc2.13-amd64

Repeat for as many cross-platform targets as wanted.

Now take your executable that you want to bundle and bundle it up for this platform:

mkbundle –cross 4.4.2-linux-libc2.13-amd64 demo.exe demo-native

Now, you can copy that “demo-native” executable to your Linux machine and run it.

I have done very minimal testing on this, and some features are missing, things that I want to add:
•         Ship native libraries
•         Add support for shipping the LLVM runtime as an option
•         Add support to target different Mono versions, not just the same you have installed

Miguel.



_______________________________________________
Mono-list maillist  -  Mono-list at lists.dot.net<mailto:Mono-list at lists.dot.net>
http://lists.dot.net/mailman/listinfo/mono-list<https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.dot.net%2fmailman%2flistinfo%2fmono-list&data=02%7c01%7cmiguel%40microsoft.com%7cf9e7ae3a341840b11ae508d3c09e04e6%7c72f988bf86f141af91ab2d7cd011db47%7c1%7c0%7c636063757323186162&sdata=kt9qFYmFdckK3tFBRtfjTnQiAMrb%2fA0MZDxoXxGwlNM%3d>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-list/attachments/20160810/f49b2744/attachment-0001.html>


More information about the Mono-list mailing list