2012-11-28 83 views
6

我有一個應用程序,我在OSX雪豹下用Qt 4.7.4編譯和運行,但是macbook死了。我現在正在建立一個新的運行山獅(10.8.2)和Qt 4.8.3的macbook。我可以建立我的應用程序,但是當我嘗試從Qt Creator的2.6.0中運行它,我得到這個運行時錯誤:qt mac osx 10.8 dyld:library not loaded ...圖像未找到

dyld: Library not loaded: ../lib/libicudata.46.1.dylib 
    Referenced from: /Users/david/dev/svn/map_creator/karte-build-Desktop-Debug/debug/MapCreator.app/Contents/MacOS/MapCreator 
    Reason: image not found 
The program has unexpectedly finished. 

我收到了類似的錯誤,從Finder中運行它。

otool給我:

Davids-MacBook-Pro:map_creator david$ otool -L karte-build-Desktop-Debug/debug/MapCreator.app/Contents/MacOS/MapCreator 
karte-build-Desktop-Debug/debug/MapCreator.app/Contents/MacOS/MapCreator: 
    ../lib/libicudata.46.1.dylib (compatibility version 46.0.0, current version 46.1.0) 
    libicui18n.46.dylib (compatibility version 46.0.0, current version 46.1.0) 
    libicuuc.46.dylib (compatibility version 46.0.0, current version 46.1.0) 
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.11.0) 
    /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55179.1.0) 
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1187.34.0) 
    /Users/david/dev/qt483/lib/QtSvg_fmosoft.framework/Versions/4/QtSvg_fmosoft (compatibility version 4.8.0, current version 4.8.3) 
    /Users/david/dev/qt483/lib/QtGui_fmosoft.framework/Versions/4/QtGui_fmosoft (compatibility version 4.8.0, current version 4.8.3) 
    /Users/david/dev/qt483/lib/QtCore_fmosoft.framework/Versions/4/QtCore_fmosoft (compatibility version 4.8.0, current version 4.8.3) 
    /Users/david/dev/qt483/lib/QtXmlPatterns_fmosoft.framework/Versions/4/QtXmlPatterns_fmosoft (compatibility version 4.8.0, current version 4.8.3) 
    /Users/david/dev/qt483/lib/QtNetwork_fmosoft.framework/Versions/4/QtNetwork_fmosoft (compatibility version 4.8.0, current version 4.8.3) 
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0) 
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1669.0.0) 
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) 
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) 
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.12.0) 

的確從雪豹到山獅什麼變化,或者從Qt的4.7.4至4.8.3,是造成這個問題?或者,也許我錯過了讓我的新Macbook設置一切的一步?我仍然在學習 - 在Qt和Mac上只是一個新手,在主開發人員離開之後試圖維護這個項目。

謝謝, 大衛

回答

14

在你的Qt的項目設置,在運行時設置,您必須將路徑添加到您編譯ICU庫。有一個網格設置環境變量等。你想要的那個是DYLD_LIBRARY_PATH,並設置(或附加)到ICU庫的路徑。

這將使Qt能夠將../lib/libicudata.46.1.dylib解析爲實際的庫文件。

+4

我遇到了同樣的問題。我認爲在'.bashrc'中設置'DYLD_LIBRARY_PATH'就可以了,但是最終通過遵循你的指令來修復。更確切地說,對於新手來說,步驟如下:在項目設置面板中,按照Projects> Run(在Qt 4.8.5之類的東西下)> Run Environment> Add',然後添加'DYLD_LIBRARY_PATH',並將其設置爲所需的lib目錄。 – ying17zi

+0

非常感謝你! – appsthatmatter

+1

是否有更具擴展性的解決方案?我試圖建立一個沒有硬編碼任何東西的編譯系統,而且我對OS X的環境還算陌生。另外,我不使用Qt Creator。 –

0

Qt 5.2.0脫機安裝程序存在一個錯誤,它會導致可執行文件在根路徑而不是安裝位置中搜索Qt庫。

典型的錯誤:

dyld: Library not loaded: /usr/local/Qt-5.2.0/lib/QtGui.framework/Versions/5/QtGui 
Referenced from: /Users/JRP/Dropbox/STANFORD/CS106B/HW1/build-Life-Desktop_Qt_5_2_0_clang_64bit-Debug/Life.app/Contents/MacOS/Life 
Reason: image not found 
The program has unexpectedly finished. 

修復:

鑑於您應該運行Qt的安裝路徑之一:

sudo ln -s /Users/$USER/Qt5.2.0/5.2.0/clang_64/ /usr/local/Qt-5.2.0 

或者

sudo ln -s /Users/ito/Qt/5.2.0/clang_64/ /usr/local/Qt-5.2.0 

你的想法我假設。它只是創建一個從qt安裝位置到它正在尋找的位置的鏈接。

相關問題