[Mono-list] mkbundle on Mac OS 10.9
james at geteventstore.com
Fri Mar 14 15:46:00 UTC 2014
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.
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>
LLVM: supported, not enabled.
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).
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
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.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list