[Mono-list] mkbundle on Mac OS 10.9
James Nugent
james at geteventstore.com
Thu Mar 20 23:32:17 UTC 2014
To follow up on this and for anyone else that hits the same thing in future, the following *does* work (this is for dynamic but static also working):
$ mkbundle --deps -c -oo helloworld.o -o helloworld.c helloworld.exe
$ gcc -I/opt/mono/include/mono-2.0 -L/opt/mono/lib/ -lmonosgen-2.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ -framework Foundation -arch x86_64 -o helloworld helloworld.c helloworld.o
$ ./helloworld
Hello World
Regards,
James
On 14 Mar 2014, at 15:46, James Nugent <james at geteventstore.com<mailto:james at geteventstore.com>> wrote:
Hi,
I’m trying to get a simple example working of statically linking Mono on Mac OS Mavericks, with a 64 bit build of mono (from source), but am hitting various problems. All this works on Linux (for the most part!).
Is it actually possible to statically link mono on Mac OS, and if not what is the recommended way to deploy binaries, especially ones which really want 64 bit Mono where we don’t want users to have to build from source? I feel like I’m probably missing something - the details of what I’ve tried are below, along with a link to a repository with all the related files in.
Regards,
James
I have mono on PATH, mono --version gives:
mono JIT compiler version 3.2.8 ((detached/b1e8599 Thu 6 Mar 2014 11:44:00 GMT)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com<http://www.mono-project.com/>
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
I also have PKG_CONFIG_PATH set up to point to /opt/mono/lib/pkgconfig.
I have a simple “Hello World” console app named helloworld.exe (source and all the scripts are here: https://github.com/jen20/mono-static-linking).
Dynamic Linking
Trying the simplest example from the docs page:
mkbundle helloworld.exe --deps -o helloworld
This builds, but when running gives the following output:
dyld: Symbol not found: _kCFLocaleCountryCode
Referenced from: /opt/mono/lib//libmonoboehm-2.0.1.dylib
Expected in: flat namespace
in /opt/mono/lib//libmonoboehm-2.0.1.dylib
Trace/BPT trap: 5
Setting DYLD_LIBRARY_PATH to include /opt/mono/lib doesn’t help this, but it’s likely not the path I want to be going down anyway because I want to use sgen rather than Boehm.
Static Linking
Changing the command used to:
mkbundle --static --deps helloworld.exe -o helloworld-static
This gives me a whole stack of errors during execution of mkbundle relating to undefined symbols for x86_64, but from the output it looks like this is determining config based on the mono-2 package anyway which likely still isn’t what I want. On Linux separating the call to mkbundle and using -c, then compiling the output separately worked, so I next tried:
mkbundle --static --deps -c -o main.c -oo helloworld.a helloworld.exe
cc -o helloworld-static2 -Wall `pkg-config --cflags monosgen-2` `pkg-config --libs-only-L monosgen-2` -Wl,-static -lmonosgen-2.0 -Wl,-dynamic `pkg-config --libs-only-l monosgen-2 | sed -e "s/\-lmono-2.0 //"` main.c helloworld.a
This complains about -lpthread, which research suggested I should go and edit in the pkgconfig files to be -pthread instead. Then I get complaints about -lSystem instead.
_______________________________________________
Mono-list maillist - Mono-list at lists.ximian.com<mailto:Mono-list at lists.ximian.com>
http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20140320/66bcbf08/attachment-0001.html>
More information about the Mono-list
mailing list