[Mono-list] Compile Mono, C# and C++ into a single executable

Guillaume George george-g at klab.com
Tue Nov 6 06:28:10 UTC 2012


My company is currently developping a C# framework for a C++ game engine for
mobile games, using Mono 2.10.8.
I successfully built a minimalist version of Mono on Ubuntu (without jit)
and after having isolated the used libraries I could use it on Windows
(obviously after building the mono-2.0.dll).

The project is running without any bug in full-aot on Ubuntu and aot on
Windows as it doesn't support full-aot. 

I am now trying to port it to iOS, in order to run it on iPhone.

At the moment, our application uses the following files:
- Our C# side of the framework and user code as a C# library (.exe and
.exe.so as I compiled it in full-aot)
- a lib/ directory with mscorlib.dll and .dll.so
- a C++ executable containing the game engine and using the mono lib in
order to launch the C# framework and to do callbacks from C++ to C#.

My main question is: 
As iOS is currently forbidding using dynamic libraries, is it possible to
merge C#, C++ and the Mono Runtime into *A SINGLE executable* ?
I guess compiling everything into a single executable is possible as
MonoTouch / Unity should do something similar to deploy an application for
the AppStore.

I have already seen the mkbundle tool but if my understanding is correct, it
is only used to include the Mono Runtime and mscorlib in the C# executable. 

I tried to use mkbundle, here is the command I am using:
mkbundle -o BundledLib.exe MyCSharpLib.exe --deps --static

Sources: 1 Auto-dependencies: True
   embedding: [...]/MyCSharpLibForLinux.exe
   embedding: [...]/lib/mono/4.0/mscorlib.dll
as -o temp.o temp.s 
cc -o BundledLib.exe -Wall `pkg-config --cflags mono-2` temp.c  `pkg-config
--libs-only-L mono-2` -Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic `pkg-config
--libs-only-l mono-2 | sed -e "s/\-lmono-2.0 //"` temp.o

Moreover, when I am using the BundledLib,an error occurs saying it requires
Is mkbundle using mkbundle2 by default? If not, how could I get mkbundle2?
I also tried to use .../bin/mono-minimal/lib/mono/4.0/mkbundle.exe and I
still get the same error.

Even including lib/mono/2.0/mscorlib.dll, the C++ can't open the assembly
anymore, mono_domain_assembly_open returns 0.

I know we must contact Xamarin if we use mkbundle --static or any other way
to statically include the Mono Runtime, but getting a license because of
static linking is not an issue.
As we have our own C++ porting layer for each target platform, using an
already made solution such as MonoTouch is not possible for the time being.

Thank you very much,
Guillaume George.

View this message in context: http://mono.1490590.n4.nabble.com/Compile-Mono-C-and-C-into-a-single-executable-tp4657283.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list