0

I am trying to make my program written in Visual C# 2010 work on Linux. For that, I have used mkbundle feature, so that potential client doesn't have to install mono. Unfortunately I am not knowledgeable about Linux or Mono, so I have just followed this: c# cywgwin mono mkbundle windows 7 - cannot compile file

But for some reason mkbundle writes [FAIL] in the end, saying something about "No such file or directory". I have pasted the full text below. Does anybody know how to solve this?

$ 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]

When I tried to use mkbundle on Linux virtual machine, I successfully obtained Linux executable, but get the following error, whenever I run the program under Ubuntu Linux VM (by 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 
Community
  • 1
  • 1
Tofig Hasanov
  • 3,303
  • 10
  • 51
  • 81
  • please post output of `pkg-config --cflags --libs mono-2|dos2unix` – sehe Dec 31 '11 at 03:26
  • $ pkg-config --cflags --libs mono-2|dos2unix -mno-cygwin -mms-bitfields -mwindows -IC:/Mono-2.10.8/include/mono-2.0 -mno-cyg win -mms-bitfields -mwindows -LC:/Mono-2.10.8/lib -lmono-2.0 -lws2_32 -lpsapi -l ole32 -lwinmm -loleaut32 -ladvapi32 -lversion – Tofig Hasanov Dec 31 '11 at 03:34
  • perhaps if you disable the gcc warnings ? – IanNorton Dec 31 '11 at 08:08
  • How can I do that? And if I disable warnings, will the program work correctly after that? – Tofig Hasanov Jan 01 '12 at 04:40
  • 1
    Your ask about Linux, but your OS is Windows? Why don't you try with *mono* on a real *Linux* system?? And running `mkbundle` on Windows won't produce a *linux executable* – Basile Starynkevitch Jan 03 '12 at 06:16
  • I used mkbundle on Linux Virtual Machine. I don't know if you can call it real Linux, but I think it is pretty close – Tofig Hasanov Jan 04 '12 at 09:41
  • But then mkbundle works successfully. It is your program (or perhaps a plugin or shared library used by it) which crashes. – Basile Starynkevitch Jan 04 '12 at 13:45
  • 1
    That is true, the question is no longer about mkbundle, but rather why the program doesn't run under mono. I have modified the name of question. – Tofig Hasanov Jan 05 '12 at 09:09
  • Your question is still very confusing, the title is simple but the content is a different question. please fix – IanNorton Jan 08 '12 at 21:26

1 Answers1

5

As I said in a comment, if you want to produce a self-sufficient Linux executable binary, you should not use mkbundle on Windows. You should run mkbundle on Linux to get a Linux executable (and you probably should care about Linux-X86 in 32 bits and Linux-x86-64 in 64 bits, which are different).

I suggest you to compile and run your application in a Linux box (you could even install a Linux system inside a VM if you want). So the simplest way is to install a Linux distribution (e.g. Debian) on your machine.

I don't think you'll easily find a cross-compiler able to compile, on a Windows box, a Mono program targeted for Linux.

And what you are doing (running mkbundle on Windows) is producing a Windows executable (for Cygwin), it cannot give you a Linux binary executable, whatever option you try.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • I have done that, please check the edited question for details. I got some error again, although mkbundle worked successfully. – Tofig Hasanov Jan 04 '12 at 09:46
  • @TofigHasanov does the program run on the linux VM without running mkbundle? – IanNorton Jan 04 '12 at 20:58
  • When I simply use "mono ProgramName.exe argument", it produces the same error as when I run the "mkbundled" version (The one which starts with Unhandled Exception: System.ArgumentException: ) – Tofig Hasanov Jan 05 '12 at 09:03
  • So you have to debug that issue. – Basile Starynkevitch Jan 05 '12 at 09:48
  • Seems that the problem was in some of the AForge libraries. I had to rewrite some filters myself, and it worked fine then. Thank you! – Tofig Hasanov Jan 05 '12 at 14:12
  • I am having the same problem with a mono installation and graphics stuff that used to work before we upgraded mono to a newer version... What was the problem you had to solve in the AForge libraries? – Josh Warner-Burke Apr 18 '12 at 01:42
  • @Josh Warner-Burke I don't remember exactly, but it had to do with one of the filters for images. Perhaps conversion to grayscale. You can check that by commenting on all of your filters and then activating them one by one. This way you will find which function causes trouble. – Tofig Hasanov Aug 20 '14 at 06:28