我正在尝试使用Visual C#2010编写的程序在Linux上运行。为此,我使用了mkbundle功能,以便潜在客户端不必安装mono。不幸的是,我不了解Linux或Mono,所以我刚刚遵循这个:c# cywgwin mono mkbundle windows 7 - cannot compile file
但是由于某些原因,mkbundle最后写了[FAIL],说了“没有这样的文件或目录”。我已粘贴下面的全文。有人知道如何解决这个问题吗?
$ mkbundle -o MyProgram MyProgram.exe --deps
OS is: Windows
Sources: 1 Auto-dependencies: True
embedding: C:\cygwin\home\Synaps\MyProgram.exe
embedding: C:\Mono-2.10.8\lib\mono\4.0\mscorlib.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Drawing.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\Mono.Security.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Configuration.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Xml.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Security.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Windows.Forms.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\Accessibility.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\Mono.WebBrowser.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\Mono.Posix.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Data.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\Mono.Data.Tds.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.Transactions.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\System.EnterpriseServices.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\AForge.Imaging.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\AForge.dll
embedding: C:\Mono-2.10.8\lib\mono\4.0\AForge.Math.dll
Compiling:
as -o temp.o temp.s
gcc -mno-cygwin -g -o MyProgram -Wall temp.c `pkg-config --cflags --libs mono-2|d
os2unix` temp.o
: No such file or directory
temp.c: In function `main':
temp.c:143: warning: implicit declaration of function `g_utf16_to_utf8'
temp.c:143: warning: assignment makes pointer from integer without a cast
temp.c:158: warning: assignment makes pointer from integer without a cast
[Fail]
当我尝试在Linux虚拟机上使用mkbundle时,我成功获得了Linux可执行文件,但每当我在Ubuntu Linux VM(Oracle VM Virtual Box)下运行程序时,都会出现以下错误:
Unhandled Exception: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0
at System.Drawing.Bitmap.SetResolution (Single xDpi, Single yDpi) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:SetResolution (single,single)
at AForge.Imaging.ColorReduction.ColorImageQuantizer.ReduceColors (System.Drawing.Bitmap image, Int32 paletteSize) [0x00000] in <filename unknown>:0
at FootMeasure.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0
at System.Drawing.Bitmap.SetResolution (Single xDpi, Single yDpi) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:SetResolution (single,single)
at AForge.Imaging.ColorReduction.ColorImageQuantizer.ReduceColors (System.Drawing.Bitmap image, Int32 paletteSize) [0x00000] in <filename unknown>:0
at FootMeasure.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
答案 0 :(得分:5)
正如我在评论中所说,如果您想生成一个自给自足的 Linux 可执行二进制文件,则不应在Windows上使用mkbundle
。 您应该在Linux上运行mkbundle
以获得Linux可执行文件(您可能应该关注32位的Linux-X86和64位的Linux-x86-64,这些是不同的)。
我建议您在Linux机器中编译和运行应用程序(如果需要,甚至可以在VM中安装Linux系统)。因此,最简单的方法是在您的计算机上安装Linux发行版(例如Debian)。
我认为您不会轻易找到能够在Windows机器上编译针对Linux的 Mono 程序的交叉编译器。
你在做什么(在Windows上运行mkbundle
)正在生成一个Windows可执行文件(对于Cygwin),无论你尝试什么选项,它都无法为你提供Linux二进制文件。