我正在尝试从控制台应用程序创建可执行文件。
我已经安装了 mono,cygwin (mingw-gcc, mingw-zlib1, mingw-zlib-devel, pkg-config) 并将以下几行添加到我的 .bashrc 文件中
export PKG_CONFIG_PATH=/cygdrive/c/progra~1/Mono-3.2.3/lib/pkgconfig
export PATH=$PATH:/cygdrive/c/progra~1/Mono-3.2.3/bin
export CC="i686-pc-mingw32-gcc -U _WIN32"
But everytime I try to use mkbundle I receive the following message
有没有办法让 mkbundle 在 Windows 上正常工作?
(我使用的是windows 7 x86,mono 3.2.3,我在官方网站上找到的cygwin,xamarin studio 4.2和net framwork 4)
目前Windows下的mono版本仍然存在这个问题。发生这种情况是因为 Mono 团队将默认 GC 切换为 SGEN。因此,当您尝试使用 mkbundle 时,正如您在错误 mkbundle 实用程序中看到的那样,尝试查找mono-2库,但该库未包含在安装程序中,因此您失败了。要解决这个问题,您应该配置 mkbundle 来使用libmonosgen-2.0代替mono-2。让我们尝试这样做。
关键时刻是设置这个变量:
export PKG_CONFIG_PATH=/cygdrive/c/progra~1/Mono-3.2.3/lib/pkgconfig
如果你进入这个目录你会看到很多*.pc文件(包配置)。该文件负责在捆绑过程中配置链接库。由于某些原因,mono 团队硬编码了包配置文件和库mono-2 (see this第 492 行)。我们如何在不重建的情况下修复它mkbundle?解决方案是使用下一个捆绑脚本:
# Mono paths
mono_version="3.2.3"
export MONO=/cygdrive/c/progra~2/Mono-$mono_version
machineconfig=$PROGRAMFILES\\Mono-$mono_version\\etc\\mono\\4.5\\machine.config
export PATH=$PATH:$MONO/bin
export PKG_CONFIG_PATH=$MONO/lib/pkgconfig
# Compiller
export CC="i686-pc-mingw32-gcc -U _WIN32"
# Output file name
output_name=Prog.exe
# Produce stub only, do not compile
mkbundle --deps --machine-config "$machineconfig" -c Program.exe
# Produce helper object file. You may see errors at this step but it's a side effect of this method.
mkbundle --deps --machine-config "$machineconfig" -oo temp.o Program.exe
# Compile. Pay attention where I use monosgen-2
i686-pc-mingw32-gcc -U _WIN32 -g -o "$output_name" -Wall temp.c `pkg-config --cflags --libs monosgen-2` temp.o
# Copy libmonosgen-2.dll
cp $MONO/bin/libmonosgen-2.0.dll .
# Run
./$output_name
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)