tec*_*hno 5 gtk macos mono gtk# xamarin
我有一个用 C# 编码的应用程序,使用 Mono Framework 和 GTK# for UI。我试图为 MacOSX 创建一个静态包(包括 gtk# 和 mono 运行时)
我只是将 Mono 与我的 exe 文件捆绑在一起使用
mkbundle --static hello.exe -o --deps hello2.exe
Run Code Online (Sandbox Code Playgroud)
我得到了 exe 文件,但是当我将它拖放到终端上时,我得到了 System.DllNotFound Exception:glibsharpglue-2
我知道我需要包含 gtk# 库。但我不知道如何使用静态链接的单声道运行时来做到这一点。是否可以选择使用 mkbundle 来做到这一点。我需要得到的是一个准备好运行的最终独立包在 Mac 上。
请帮帮我。
更新:我目前与 Platypus 一起使用的 shell 脚本来制作 .app 包
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:$DYLD_FALLBACK_LIBRARY_PATH:/usr/lib"
exec /Library/Frameworks/Mono.framework/Versions/Current/bin/mono myapp.exe
Run Code Online (Sandbox Code Playgroud)
我目前正在使用 platypus 中提供的选项来包含 myapp.exe 文件。如何包含 GTK 所需的 dll?请帮帮我。
The error is from not finding the GTK shared object libraries (SO/dylib).
Using mkbundle
:
If using 32-bit Mono you will need to assign the arch type for AS and CC. By default, clang will compile and link x86_64 which may not match your installed Mono's arch type.
export AS="as -arch i386"
export CC="cc -arch i386 -framework CoreFoundation -lobjc -liconv"
mkbundle gtkdesigner.exe --deps -o gtkdemo
Run Code Online (Sandbox Code Playgroud)
The resulting executable will still require Mono (and any dependant shared objects/dylibs) to be installed.
Or adding --static
to statically link to mono libs and thus invoking the LGPL of Mono (you will need to distribute your original CIL images so the user can upgrade the version of Mono that is running your app, unless you have a license from Xamarin)
mkbundle --static gtkdesigner.exe --deps -o gtkdemo
Run Code Online (Sandbox Code Playgroud)
The resulting executable will not require Mono to be installed, but any dependant shared objects/dylibs will still be required.
GTK/GTK# based applications:
A GTK# based application will still require the GTK shared objects/dylibs to be installed and accessible by the resulting executable (i.e. gtkdemo in this case):
Thus if you try to run ./gtkdemo
it will need to find shared libraries such as libc.dylib, libgtksharpglue-2.so, etc, etc... otherwise the error you are getting will be shown.
Set the dylib library path to your GTK libraries, not the C# CIL binding library (GTK#), but the native shared object libraries. Since you have Mono installed on OS-X, it also installs its own version of GTK that can be found at /Library/Frameworks/Mono.framework/Versions/Current/lib
. If you are installing your own version GTK to a different location just change the path to that location. You also will be to include the location of the OS's std C library.
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:/usr/lib"
./gtkdemo
Run Code Online (Sandbox Code Playgroud)
Note: You can package this gtkdemo
application into a normal OS-X app by using a packager tool such as http://sveinbjorn.org/platypus. Package all the GTK libraries and any other required so/dylibs into the app
and provide a shell script that assigns the DYLIB path in order to find those app
based GTK libs. Then you can distribute the self-contained app
and the end-user just double-clicks it to run you GTK-based app.