Mono mkbundle tool unable to create binary with co

2019-07-16 11:11发布

问题:

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...

回答1:

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.