Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

A C# file in mono can be compiled using gmcs command. This will create a hello.exe file.

$ gmcs hello.cs
$ ls
hello.cs  hello.exe
$ ./hello.exe
Hello from Mono!

To generate a linux executable, I tried this command, but it generates the error:

$ gmcs /t:exe hello.cs /out:hello

Unhandled Exception: System.ArgumentException: Module file name 'hello' must have file extension.

I want create a standalone executable so that I can execute it simply run it by saying and I get the desired output:

$ ./hello
Hello from Mono!

I searched and found a solution which mentions of a tool called mkbundle:

$ mkbundle -o hello hello.exe --deps
Sources: 1 Auto-dependencies: True
embedding: /home/ed/Projects/hello_world/hello.exe
embedding: /mono/lib/mono/1.0/mscorlib.dll
Compiling:
as -o /tmp/tmp54ff73e6.o temp.s
cc -o hello -Wall temp.c `pkg-config --cflags --libs mono` /tmp/tmp54ff73e6.o
Done

$ ls -l
total 3
-rwxr-xr-x  1 ed users 1503897 2005-04-29 11:07 hello
-rw-r--r--  1 ed users     136 2005-04-29 11:06 hello.cs
-rwxr-xr-x  1 ed users    3072 2005-04-29 11:06 hello.exe

This utility does not seem to exist in my Mono install. I found that this is available in mono-devel package. To install this package meant installing around 82 other packages. My goal was to keep my mono install minimal until sometime.

Is there a way to install mkbundle standalone?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I was very impatient and felt that the package mono-2.0-devel might have mkbundle. So I went ahead and installed mono-2.0-devel which needed only 18 additional packages. When I typed mkb and hit tab, it showed me mkbundle2.

I tried:

$ mkbundle2 -o hello hello.exe --deps
OS is: Linux
Sources: 1 Auto-dependencies: True
   embedding: /home/minato/Projects/Practice/mono/hello.exe
   embedding: /usr/lib/mono/2.0/mscorlib.dll
Compiling:
as -o temp.o temp.s 
cc -ggdb -o hello -Wall temp.c `pkg-config --cflags --libs mono`  temp.o
Done

$ ls
hello  hello.cs  hello.e  hello.exe

$ ./hello
Hello from Mono!

This was what I needed in the first place.

Thanks to the command-not-found tool.

share|improve this answer
    
That hello.e was a result of an earlier typo in the parameter for /out:filename –  Nanda Apr 16 '12 at 11:30
1  
In case you're using a Debian-based system: You can search for file names in packages with apt-file, e.g. apt-file search mkbundle. This tells me that mkbundle is in package mono-devel (I'm on Ubuntu 11.10). –  daniel kullmann Apr 16 '12 at 14:07
    
Thank you daniel. –  Nanda Apr 17 '12 at 14:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.