views:

616

answers:

1

As per suggestions from this thread on running C# apps sans .NET I've compiled my app using mono. I built the original app using the latest Visual C# .NET Express Edition. It runs fine on .NET on Windows. I then opened up Cygwin and navigated to my source where I compiled the project again, under mono using the following command:

$ mcs <myProjectHere>.cs

This produces MyProject.exe, which can be run from within Cygwin with success, and can be run from the Window command line successfully. Commands used are:

$ mono MyProject.exe
C:\...>mono MyProject.exe

and just for kicks, simply:

C:\...>MyProject.exe

All work as expected. I then tried to build the mono compiled executable into a statically linked binary using the mkbundle command as follows:

$ mkbundle -o MyProject MyProject.exe --deps

This is where things begin to go downhill. It starts off well enough and then complains that the output file (presumably, MyProject.exe) cannot be opened because it is busy. The full output of it all is here:

    $ mkbundle -o Program Program.exe --deps
    OS is: Windows
    Sources: 1 Auto-dependencies: True
       embedding: c:\Documents and Settings\bsweeney\My Documents\Visual Studio 2008
    \Projects\TestConsole\TestConsole\Program.exe
       embedding: C:\PROGRA~1\Mono-2.2\lib\mono\2.0\mscorlib.dll
    Compiling:
    as -o temp.o temp.s
    gcc -mno-cygwin -g -o Program -Wall temp.c `pkg-config --cflags --libs mono|dos2
    unix`  temp.o
    /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/bin/ld: cannot op
    en output file Program.exe: Device or resource busy
    collect2: ld returned 1 exit status
    [Fail]

I claim that my unix gcc toolchain is installed and in good condition because I've been able to successfully compile a few c++ apps in eclipse using it recently (although i supposed i should be open to any number of problems...).

Anyone ever run into anything like this? I'm stumped...

+3  A: 

It seems like it's trying to output into MyProject.exe, which is the same as the input file.

Try running

$ mkbundle -o ProgramOutput Program.exe --deps

This is just a guess, by the way, since I don't know mkbundle.

configurator
This actually worked! I thought that `Program` and `Program.exe` would be two distinct files but it turns out the `cygwin` or maybe `mkbundle` was appending `.exe` onto the end of `Program`.
sweeney
Wow, my psychic powers are getting better! The hint was the message 'cannot open output file Program.exe', by the way.
configurator
makes sense - i assumed it was referring to the input program which *was* in fact named Program.exe. in any event i now see the error of my ways... thanks!
sweeney