无法使用Mkbundle编译简单的C#应用程序 [英] Can not compile simple C# application with mkbundle
问题描述
我写了一些类似"Hello world"的控制台应用程序.并遵循 c#cywgwin mono mkbundle Windows 7-无法编译文件答案.但是我有:
I have written some console "Hello world"-like app. and have followed c# cywgwin mono mkbundle windows 7 - cannot compile file answer. But I have got:
$ mkbundle -o Fur Furries.exe --deps -z
OS is: Windows
Sources: 1 Auto-dependencies: True
embedding: C:\Monotest\Furries.exe
compression ratio: 40.43%
embedding: C:\Soft\Mono\lib\mono\4.0\mscorlib.dll
compression ratio: 34.68%
Compiling:
as -o temp.o temp.s
gcc -mno-cygwin -g -o Fur -Wall temp.c `pkg-config --cflags --libs mono-2|dos2un
ix` -lz temp.o
temp.c: In function `main':
temp.c:173: warning: implicit declaration of function `g_utf16_to_utf8'
temp.c:173: warning: assignment makes pointer from integer without a cast
temp.c:188: warning: assignment makes pointer from integer without a cast
/tmp/ccQwnxrF.o: In function `main':
/cygdrive/c/Monotest/temp.c:173: undefined reference to `_g_utf16_to_utf8'
/cygdrive/c/Monotest/temp.c:188: undefined reference to `_g_utf16_to_utf8'
collect2: ld returned 1 exit status
[Fail]
它在Windows XP中.
It's in Windows XP.
推荐答案
首先,准备开发环境:
- 安装Mono.例如,您已将其安装到"
C:\Soft\Mono
". - 安装Cygwin.选择要安装的软件包时,请选择以下内容:gcc-mingw,mingw-zlib,pkg-config,nano.
- 启动Cygwin Bash shell(使用链接或"
bash --login -i
"命令). - 用"nano"("
nano ~/.bashrc
")打开"$HOME/.bashrc
".不要使用不保留行尾("CR","LF","CR/LF"或其他字符)的编辑器,否则会损坏文件! -
在文件末尾添加以下行:
- Install Mono. For example, you have installed it into "
C:\Soft\Mono
". - Install Cygwin. When selecting which packages to install select following: gcc-mingw, mingw-zlib, pkg-config, nano.
- Start Cygwin Bash shell (either using a link or "
bash --login -i
" command). - Open "
$HOME/.bashrc
" with "nano" ("nano ~/.bashrc
"). Don't use editors which don't preserve end-of-line-s ("CR", "LF", "CR/LF" or other), or it will corrupt the file! Add following lines to the end of the file:
export PKG_CONFIG_PATH=/cygdrive/c/Soft/Mono/lib/pkgconfig
export PATH=$PATH:/cygdrive/c/Soft/Mono/bin
重新启动Cygwin Bash shell.
Restart Cygwin Bash shell.
之后,您可以使用"mkbundle"编译程序集:
After that you can compile your assemblies with "mkbundle":
- 执行以下命令:"
mkbundle -c -o host.c -oo bundle.o --deps YourAssembly.exe <additional arguments>
".您也可以选择传递"-z
"来压缩生成的包.您应该获得"host.c"和"bundle.o"文件. -
在"host.c"中,应删除"_WIN32""branch"("
#include <windows.h>
"除外).它不起作用.您可以通过在其中的以下几行之后添加"#undef _WIN32
"来完成此操作:
- Perform the following command: "
mkbundle -c -o host.c -oo bundle.o --deps YourAssembly.exe <additional arguments>
". You also may optionally pass "-z
" to compress resultant bundle. You should get "host.c" and "bundle.o" files. In "host.c" you should remove "_WIN32" "branch" (except "
#include <windows.h>
" one). It doesn't work. You may do it just by adding "#undef _WIN32
" right after following lines in it:
#ifdef _WIN32
#include <windows.h>
#endif
所以您会得到:
#ifdef _WIN32
#include <windows.h>
#endif
#undef _WIN32
执行以下命令:"gcc -mno-cygwin -o ResultantBundle.exe -Wall host.c
`pkg-config --cflags --libs mono-2|dos2unix`
bundle.o <additional arguments>
".如果在步骤2中添加了-z附加参数,则必须在此步骤中添加-lz附加参数.
Perform the following command: "gcc -mno-cygwin -o ResultantBundle.exe -Wall host.c
`pkg-config --cflags --libs mono-2|dos2unix`
bundle.o <additional arguments>
". If you added a -z additional argument in step 2, you must add a -lz additional argument in this step.
这篇关于无法使用Mkbundle编译简单的C#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!