Hi, David,
I followed your advice and now my program runs fine on mac but I found other issues I would like to point out to you::

If there are dlls with the same name in the current folder, mkbundle ignores the path on the command line (look path of System.dll):

$ mkbundle --deps --static --cross mono-5.0.1-osx-10.7-i386.zip -o launcher-mac CHElauncher.exe /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/System.dll
From: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip
Using runtime: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/bin/mono
     Assembly: /home/jak/mac/CHElauncher
     Assembly: /home/jak/mac/System.dll
Assembly: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/I18N.West.dll Assembly: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/I18N.dll
Generated launcher-mac

(now I remove local file System.dll)

$ rm System.dll

$ mkbundle --deps --static --cross mono-5.0.1-osx-10.7-i386.zip -o launcher-mac CHElauncher.exe /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/System.dll
From: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip
Using runtime: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/bin/mono
     Assembly: /home/jak/mac/CHElauncher
Assembly: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/System.dll Assembly: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/I18N.West.dll Assembly: /home/jak/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/I18N.dll
Generated launcher-mac

Also, I've looked at mkbundle source code on https://github.com/mono/mono/blob/master/mcs/tools/mkbundle/mkbundle.cs. I do not have the ability to use debugging tools on it, but it seems that in the QueueAssembly function, the first time recursively called, the first if is satisfied, so it ends up returning true, true again and stops its work. To follow, I send you the piece of code that I used to find out about the dependencies of my program. It is not recursive and seems to do its job properly. I've grubbed it here: https://stackoverflow.com/questions/851248/c-sharp-reflection-get-all-active-assemblies-in-a-solution .

        staticintMain(string[]args)
{
List<string>ass_name=newList<string>();

try
{
foreach(var e inGetAssemblies(@args[0]))
ass_name.Add(e.GetName().Name);

foreach(var e inass_name)
Console.WriteLine(e);
}
catch(Exception e)
{
Console.WriteLine("Anexceptionoccurred:{0}",e.Message);
return1;
}
return0;
}

publicstaticIEnumerable<Assembly>GetAssemblies(stringfname)
{
varlist=newList<string>();
varstack=newStack<Assembly>();
Assemblyasm=null;
stack.Push(Assembly.LoadFile(fname));

do
{
asm=stack.Pop();

yieldreturnasm;

foreach(var reference inasm.GetReferencedAssemblies())
{
if(!list.Contains(reference.FullName))
{
stack.Push(Assembly.Load(reference));
list.Add(reference.FullName);
}
}
}
while(stack.Count>0);
}

I noticed another thing in mkbundle source code: the VerifySdk function verifies the presence of the runtime in sdk_path/bin/mono but in the windows environment there is no file called 'mono' in the folder, there is only mono.exe

Thank you again for your attention.
Greetings.

Il 27/06/2017 14:06, David Curylo ha scritto:
You need to also add System.dll to the command line, and you’ll find that you have to add all of those other libraries, as well as possibly a few other that are under /usr/lib/mono/4.5/Facades if you use things like from those libraries like TaskExtensions from System.Threading.Tasks.dll. According to the docs, --deps is supposed to discover those, but I’ve never been able to get it to find them even though things are directly referenced (not loading by reflection or anything).

I think you also need the --static flag to embed the mono runtime libraries.

On Jun 27, 2017, at 5:27 AM, dmaxime via Mono-devel-list <mono-devel-list@lists.dot.net <mailto:mono-devel-list@lists.dot.net>> wrote:

Hello everybody,
I would like to build a 'all in one' OSX program from linux (ubuntu).

This is the linux version I'm using:
Linux 4.4.0-81-generic #104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

This and the Mono version installed:
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Thu May 25 09:16:53 UTC 2017) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug
    LLVM:          supported, not enabled.
    GC:            sgen (concurrent by default)

These are the necessary frameworks to run my program:
    Microsoft.CSharp.dll
    System.Configuration.dll
    System.Data.DataSetExtensions.dll
    System.Data.dll
    System.Deployment.dll
    System.dll
    System.Drawing.dll
    System.IO.Compression.dll
    System.IO.Compression.FileSystem.dll
System.Net <http://system.net>.Http.dll
    System.Runtime.Serialization.dll
    System.Web.dll
    System.Web.Extensions.dll
    System.Windows.Forms.dll
    System.Xml.dll
    System.Xml.Linq.dll

I took the following environments using the command "mkbundle --fetch-target":
mono-5.0.1-osx-10.7-i386.zip

I ran the build, using mkbundle, with the following command:
$ mkbundle --deps --cross mono-5.0.1-osx-10.7-i386.zip -o launcher-mac CHElauncher.exe

And this is the resulting output:
From: ~/.mono/targets/mono-5.0.1-osx-10.7-i386.zip
Using runtime: ~/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/bin/mono
    Assembly: ~/mac/CHElauncher.exe
Assembly: ~/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/I18N.West.dll Assembly: ~/.mono/targets/mono-5.0.1-osx-10.7-i386.zip/lib/mono/4.5/I18N.dll
Generated launcher-mac

Note that my program runs fine in windows, linux and mac environments but when I move the resulting file from the build to the mac pc, where no mono environment is installed, and run it, I get the following error:
$ ./CHElauncher.exe
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/4.5/mscorlib.dll' directory.


I also tried to add mscorlib.dll to the command line mkbundle and I received this error:

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. File name: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. File name: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Could you explain to me what I'm wrong?

Thanks in advance for your attention.


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.dot.net <mailto:Mono-devel-list@lists.dot.net>
http://lists.dot.net/mailman/listinfo/mono-devel-list


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.dot.net
http://lists.dot.net/mailman/listinfo/mono-devel-list

Reply via email to