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?