
mono 中的 AC# 檔案可以使用指令編譯gmcs
。這將創建一個hello.exe
文件。
$ gmcs hello.cs
$ ls
hello.cs hello.exe
$ ./hello.exe
Hello from Mono!
為了產生 Linux 可執行文件,我嘗試了這個命令,但它產生了錯誤:
$ gmcs /t:exe hello.cs /out:hello
Unhandled Exception: System.ArgumentException: Module file name 'hello' must have file extension.
我想創建一個獨立的可執行文件,以便我可以執行它,只需運行它即可獲得所需的輸出:
$ ./hello
Hello from Mono!
我搜尋並找到了一個解決方案,其中提到了一個名為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
我的 Mono 安裝中似乎不存在該實用程式。我發現這個可以在mono-devel
包裝中找到。安裝此軟體包意味著安裝約 82 個其他軟體包。我的目標是在某個時候保持我的單聲道安裝最小化。
有沒有辦法mkbundle
獨立安裝?
答案1
我很不耐煩,覺得包包裡mono-2.0-devel
可能有mkbundle。所以我繼續安裝,mono-2.0-devel
只需要 18 個額外的軟體包。當我輸入mkb
並點擊 Tab 時,它顯示了mkbundle2
.
我試過:
$ 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!
這就是我首先需要的。
感謝該command-not-found
工具。