qt mac osx 10.8 dyld: library not loaded…image not

2020-06-03 06:24发布

I have an app I was building and running fine under osx snow leopard with Qt 4.7.4, but that macbook died. I now am setting up a new macbook running mountain lion (10.8.2) and Qt 4.8.3. I can build my app, but when I try to run it from within Qt Creator 2.6.0, I get this run time error:

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.

I get a similar error running it from Finder.

otool gives me:

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)

Did something change from snow leopard to mountain lion, or from Qt 4.7.4 to 4.8.3, that is causing this issue? Or maybe I missed a step getting everything set up on my new macbook? I'm still learning - really just a novice on both Qt and Mac, trying to maintain this project after the primary developer has left.

Thanks, David

标签: macos qt dyld
3条回答
ら.Afraid
2楼-- · 2020-06-03 06:40

On Qt 5.11.3, I restarted the QtCreator and the problem got resolved!

查看更多
家丑人穷心不美
3楼-- · 2020-06-03 06:48

In your Qt project settings, under runtime settings, you will have to add the path to the ICU libraries that you compiled. There is a grid where you set environment variables, etc. The one you want is DYLD_LIBRARY_PATH, and set (or append) the path to the ICU libraries.

That will enable Qt to resolve ../lib/libicudata.46.1.dylib to the actual library file.

查看更多
虎瘦雄心在
4楼-- · 2020-06-03 06:58

There is a bug in the Qt 5.2.0 offline installer which causes the executables to search for the Qt libraries in the root path instead of the install locations.

Example error:

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.

Fix:

Given the Qt installation path you should run either:

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

Or

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

You get the idea I suppose. It just creates a link from the qt installation location to the location it is looking for.

查看更多
登录 后发表回答