2012-12-14 41 views
6

我想在C#中執行我的第一步,並希望構建一個空的GTK窗口作爲我的第一個任務。通過macports我安裝了以下軟件包:單聲道在OSX上:找不到gtksharpglue-2.dll

我也用的MonoDevelop從Mono主頁。

我將gtk-sharp.dll(從/opt/local/lib/mono/gtk-sharp-2.0)加到我的參考文獻中。 我的代碼如下所示:

using System; 
using Gtk; 

namespace lolbr_client 
{ 
    class MainClass 
    { 
     public static void Main (string[] args) 
     { 
      Console.WriteLine("Loading.."); 
      Window window = new Window("test"); 
     } 
    } 
} 

當我編譯和運行代碼片段,似乎在尋找和包括GTK庫,它打印「中..」到控制檯,但經過Console.WriteLine()原因線這個錯誤:

System.DllNotFoundException: gtksharpglue-2 
    at (wrapper managed-to-native) Gtk.Container:gtksharp_gtk_container_get_focus_child_offset() 
    at Gtk.Container..cctor() [0x00000] in <filename unknown>:0 

雖然特定的.dll不上我的文件系統存在,快速locate gtksharpglue-2揭示了以下文件:

/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgtksharpglue-2.so 
/opt/local/lib/libgtksharpglue-2.a 
/opt/local/lib/libgtksharpglue-2.la 
/opt/local/lib/libgtksharpglue-2.so 

這些文件對我有幫助嗎?從這裏進行調試/修復的下一步是什麼?我已經搜索了Google,但是我對這個主題太陌生,不能識別有用的信息,或者有用的信息根本不存在。有人能幫我嗎?提前致謝!

回答

11

如何運行GTK夏普MONO應用程序(編譯例如與Xamarin工作室)解決方案是做以下:

  1. 編譯您單聲道/ gtk-尖銳的應用作爲版本

  2. 創建shell腳本文件(bash)像這樣(無論如何命名它)

    [sharp]!/bin/sh 
    
    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 ./AsketicExcel.exe 
    

enter image description here

_3。然後你可以運行這個表格終端,或者你可以使用這個包裝工具http://sveinbjorn.org/platypus並創建正常的OSX應用:)(包括在發佈目錄中的所有文件包)

然後,爲了在其他mac上運行這個應用程序,需要安裝GTK#&單聲道運行http://www.go-mono.com/mono-downloads/download.html

它到底會是什麼樣子: enter image description here

4

我發現這個問題,我的dllmap是不完整的。

添加以下行/Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/config

<dllmap os="osx" dll="libgtk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgtk-quartz-2.0.0.dylib" /> 
<dllmap os="osx" dll="glibsharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libglibsharpglue-2.so" /> 
<dllmap os="osx" dll="libgthread-2.0-0" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgthread-2.0.0.dylib" /> 
<dllmap os="osx" dll="libgthread-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgthread-2.0.0.dylib" /> 
<dllmap os="osx" dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libglib-2.0.0.dylib" /> 
<dllmap os="osx" dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgobject-2.0.0.dylib" /> 
+0

那些dllmaps應該已經有了gtk-sharp,請注意找到問題的根本原因,以便我們爲下一個開發人員修復上游問題? – knocte

+0

@knocte我會研究它。我假定像'glib'這樣的依賴項在安裝之後就已經配置好了,所以也許這就是問題所在。你是一個單聲道或gtk尖銳的開發者? – Fabian

+0

是我貢獻了兩個 – knocte

1

就遇到了這個問題藏漢儘管Fabian的答案是正確的軌道上,這是不是解決了我。根據this bug filed with Xamarin,要求將dllmap的以下條目添加到/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/config(刪除了幾個副本)。

<dllmap os="osx" dll="glibsharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglibsharpglue-2.so" /> 
<dllmap os="osx" dll="gthread-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgthread-2.0.0.dylib" /> 
<dllmap os="osx" dll="gthread-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgthread-2.0.dylib" /> 
<dllmap os="osx" dll="glib-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib" /> 
<dllmap os="osx" dll="glib-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.dylib" /> 
<dllmap os="osx" dll="glibsharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglibsharpglue-2.so" /> 
<dllmap os="osx" dll="gtksharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtksharpglue-2.so" /> 
<dllmap os="osx" dll="gobject-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib" /> 
<dllmap os="osx" dll="gobject-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.dylib" /> 
<dllmap os="osx" dll="gtk-quartz-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtk-quartz-2.0.0.dylib" /> 
<dllmap os="osx" dll="gtk-quartz-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtk-quartz-2.0.dylib" />