2011-09-05 42 views
0

我正在尝试使用mkbundle,以便我可以分发GTK#应用程序,而无需用户安装.NET/Mono或GTK#。我已经成功捆绑了一个使用winforms的应用程序,但由于某种原因,当我对GTK#应用程序进行相同操作时,它将无法工作。mkbundle和GTK#

这是我走出的Cygwin:

$ mkbundle --deps a.exe OS is: Windows Sources: 1 Auto-dependencies: True

未处理的异常:System.IO.FileNotFoundException:未能加载文件或程序集“GTK锋利”或它的一个依赖。该系统找不到指定的文件。
文件名: 'GTK的尖锐'
在System.AppDomain.Load(System.Reflection.AssemblyName assemblyRef,System.Security.Policy.Evidence assemblySecurity)[0x00000]在:0
在(包装远程-invoke- (System.AppDomain:Load(System.Reflection.AssemblyName,System.Security.Policy.Evidence)
at System.AppDomain.Load(System.Reflection.AssemblyName assemblyRef)[0x00000] in:0
at(包装远程-调用与 - 检查)System.AppDomain:载荷(System.Reflection.AssemblyName)
在System.Reflection.Assembly.Load(System.Reflection.AssemblyName assemblyRef)[0x00000]在0到M
akeBundle.QueueAssembly(System.Collections.ArrayList files,System.String codebase)[0x00000] in:0
at MakeBundle.Main(System.String [] args)[0x00000] in:0
[ERROR] FATAL UNHANDLED EXCEPTION :System.IO.FileNotFoundException:无法加载文件或程序集“gtk-sharp”或其某个依赖项。该系统找不到指定的文件。
文件名: 'GTK的尖锐'
在System.AppDomain.Load(System.Reflection.AssemblyName assemblyRef,System.Security.Policy.Evidence assemblySecurity)[0x00000]在:0
在(包装远程-invoke- (System.AppDomain:Load(System.Reflection.AssemblyName,System.Security.Policy.Evidence)
at System.AppDomain.Load(System.Reflection.AssemblyName assemblyRef)[0x00000] in:0
at(包装远程-调用与 - 检查)System.AppDomain:载荷(System.Reflection.AssemblyName)
在System.Reflection.Assembly.Load(System.Reflection.AssemblyName assemblyRef)[0x00000]在0到M
akeBundle.QueueAssembly(System.Collections.ArrayList文件,代码库System.String)[0x00000]在:0
在MakeBundle.Main(System.String []参数)[0x00000]中:0`

但但我的PATH变量中有/cygdrive/c/GtkSharp/2.12/lib。我可以检查这一点,因为如果我输入“GTK的sharp.dll”进入cygwin的我碰到下面的返回:

$ gtk-sharp.dll bash: /cygdrive/c/GtkSharp/2.12/lib/gtk-sharp-2.0/gtk-sharp.dll: cannot execute binary file

所以它应该是能够找到的文件!

任何帮助将不胜感激。

+0

尝试给mkbundle每个程序集的完整路径 – IanNorton

+0

mkbundle带回“找不到程序集”/cygdrive/c/GtkSharp/2.12/lib/gtk-sharp-2.0/gtk-sharp.dll'为什么不能mkbundle只是工作! – Joe

回答

1

我发现了一个shell脚本,做了这一切,它修改为最新的版本,2013年5月,你可以只使用脚本如下:

https://gist.github.com/tebjan/5581296

1)安装cygwin,使务必选择以下软件包: - GCC-MinGW的 - pkg配置 - MinGW的-zlib1 - MinGW的-的zlib-devel的

2)安装单发行包:“单为Windows,GTK#,和XSP“

3.)下载脚本将它放在您的应用程序之外,并根据您的环境进行修改(仔细阅读文件中的注释)。 4.打开cygwin并导航到你的应用程序的可执行文件和scipt所在的输出文件夹,例如:http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn YourProject /斌/释放

5)用命令执行该脚本:./mkbundle_cygwin.sh

故障排除: 如果你的可执行文件捆绑在一起不工作应确保原.NET应用程序适用于单声道。您可以通过调用mono.exe并将您的.NET应用程序传递给它,或通过安装XamarinStudio并从那里运行您的项目(使您将mono设置为运行时)来测试。

1

好的我不知道这是否是一个真正的解决方案,但我只是将程序集从C:\ GtkSharp \ 2.12 \ lib \ gtk-sharp-2.0复制到C:\ Mono-2.10.5 \ lib \单声道\ 4。0现在看来使用以下步骤捆绑OK:

mkbundle -c -o host.c -oo bundle.o --deps app.exe

nano host.c

变化从以下方面:

#ifdef _WIN32 
#include <windows.h> 
#endif` 

#ifdef _WIN32 
#include <windows.h> 
#endif 
#undef _WIN32 

最后:

gcc -mno-cygwin -o bundled.exe -Wall host.c `pkg-config --cflags --libs mono-2|dos2unix` bundle.o 

这对我有效。虽然我也有些东西需要将machine.config从C:\ Mono-2.10.5 \ etc \ mono \ 4.0复制到我的应用程序所在的目录,并将-machine-config machine.config传递给mkbundle。