I'm a long-time C# developer but new to Mono and, especially, Gtk#. I have developed a small app using C# and Gtk#. I need this app to work on Windows, Linux and Mac so I decided to go for Mono and, so far, it seems to be a cool framework.
What my simple app does is start up an XSP web server based on a local directory and port chosen by the user. Ideally, I would like my app to work without having to install the Mono framework at first, but this is not a must to begin with. I am using the following libraries:
using System;
using Gtk;
using System.Net;
using Mono.WebServer;
using System.Diagnostics;
I am developing on a Mac (Snow Leopard, 10.6.7). My executable works perfectly on my Mac. But I am having problems with Ubuntu and Windows. My app works partly on Ubuntu (11.04) -- it starts up and seems to be working but fails when I try to start the XSP web server, which seems expectable as Mono.Webserver is probably not installed on my Ubuntu machine. On Windows (7, 64-bit), my app crashes immediately when I double-click on it. The crash report tells me that a System.IO.FileNotFoundException error occurred. Probably due to the same missing XSP library?
Anyway, I looked around on the Internet and learned about mkbundle
. I have performed the following setting as suggested by various forum threads:
export AS="as -arch i386"
I have navigated to the /bin/Release directory of my project and, then, run the follo开发者_Go百科wing command:
mkbundle MivandoLocalServer.exe -o MivandoLocalServer --deps
But I am getting the following output, which eventually fails:
Compiling:
as -arch i386 -o temp.o temp.s
cc -g -o MivandoLocalServer -Wall temp.c `pkg-config --cflags --libs mono-2` temp.o
Package mono-2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `mono-2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mono-2' found
temp.c:2:36: error: mono/metadata/assembly.h: No such file or directory
temp.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘assembly_bundle_MivandoLocalServer_exe’
temp.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
temp.c:18: error: ‘NULL’ undeclared here (not in a function)
temp.c: In function ‘mono_mkbundle_init’:
temp.c:22: warning: implicit declaration of function ‘mono_register_bundled_assemblies’
temp.c:22: error: ‘bundled’ undeclared (first use in this function)
temp.c:22: error: (Each undeclared identifier is reported only once
temp.c:22: error: for each function it appears in.)
temp.c: In function ‘main’:
temp.c:114: warning: implicit declaration of function ‘mono_set_dirs’
[Fail]
I really do not know what to do from here. I have MacPorts installed and I have read that this might cause some problems with regards to the pkg-config directory. Is this true? If yes, what will I have to do make it work?
I hope that somebody will be able to help me. Thanks!
Best regards, Sebastian
PS. I have also posted this question in the forums at Mono's homepage but without any responses so far.
Update: I suspect MacPorts for interfering with my pkg-config directory setting. When I entered the following commands into my terminal, mkbundle allowed me to compile. But I am still encountering some problems.
export PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/"
export AS="as -arch i386"
export CC="cc -arch i386"
Executing the following mkbundle
command results in a Unix-archive of 4.9 MB that includes all the necessary dependencies. When I double-click on this new file on my Mac, a terminal window pops up and starts my app. Sweet! But this does not work in Windows nor in Ubuntu.
mkbundle MivandoLocalServer.exe -o MivandoLocalServerBundle --deps -z
What I would like to receive is a bundled executable that can be run in Windows and Ubuntu. So far I have not come across a solution that lets me do this. I tried to install MonoDevelop on my Windows 7 machine, copy my solution and build it there. But since my app is dependent on the Mono.WebServer2
library, I am not able to build it on Windows. I have not been able to find the Mono.WebServer2.dll
to download for Windows anywhere on the Internet.
First of all this situation covers two separate issues which I will address separately:
- Architecture - i386 only
- Build and Packaging
1. Architecture
First of all, not all Windows and Linux machines run on the i386 architecture, so make sure you are using one that is. They are more likely to be i386, but Linux can easily run on many architectures and Windows has recently ventured into this path as well (they supported it in the past, but it quickly lost support) with the new tablet PC cpu types.
2. Build and Packaging
When targeting any operating system there are bound to be differences in the packaging paths so you should build for each target OS with that target OS. If you want mkbundle to work on Windows the whole toolchain needs to be installed there and Windows requires a special script to get it right, but since mkbundle was made for Unix-like OSs it should work on Linux without special considerations:
Create C# executable with mkbundle on windows
http://linux.die.net/man/1/mkbundle
精彩评论