[Mono-dev] Patch for mkbundle and embedding Mono
Joshua Tauberer
jit at occams.info
Wed Nov 29 15:12:44 EST 2006
Hi,
I recently found that I could use mkbundle to embed Mono and some
assemblies within an existing native application -- that is, to use
mkbundle not to create a standalone executable, but to package
everything up in a single .o object file. To do this, I generated the c
stub with the -c option and then basically removed the main() function,
and then linked that into the native app.
I'm attaching a patch that adds a new option --nomain so that mkbundle
can be used to create the c wrapper file without a "int main(...)"
function so that it can be embedded as a library in other applications.
To do this, I factored out the "int main(...)" code from the
initialization stuff in the C templates and put it into a separate template.
With the patch, the --nomain option only works with the -c (generate
code but don't compile & link) option. In order to make it work without
-c (to produce the .o file directly), the gcc command line arguments
would have to be modified to produce the .o instead of the linked
executable, and I didn't want to get into that (yet).
(Btw--- This was for one of the most rapid projects I've ever done. In
3 hours, I took an existing app with a strange internal scripting
language and replaced the scripting language with JavaScript, by
convering the Rhino interpreter from Java to .NET (with my favorite tool
IKVM), embedding Mono in the native app, and using mkbundle to embed
Rhino and other assemblies within the app. The next step is to get JB's
Linker tool to cut down the IKVM libs to just what I need to embed.)
Comments/permission?
--
- Josh Tauberer
http://razor.occams.info
"Yields falsehood when preceded by its quotation! Yields
falsehood when preceded by its quotation!" Achilles to
Tortoise (in "Gödel, Escher, Bach" by Douglas Hofstadter)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkbundle.diff
Type: text/x-patch
Size: 4868 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061129/dd264131/attachment.bin
More information about the Mono-devel-list
mailing list