[Mac] Load shared libraries from bundle
-
wrote on 20 Mar 2012, 21:32 last edited by
Hi,
in my app, I use and link to my private library (dylib on Mac).
Now I want to put this library into bundle and load it from there.
App is in app.app/Contents/MacOS/app_name and libary in app.app/Contents/MacOS/library.dylib .I tried to add RPATH to @executable_path with no success (app cannot be run because of missing library)
So is there a way (in qmake) to achieve loading shared libraries from bundle?Thanks for any answer.
-
wrote on 5 Apr 2012, 11:58 last edited by
You need to use install_name_tool to change the location of the library in you executable. Have a look at the "OS X deployment guide":http://qt-project.org/doc/qt-4.8/deployment-mac.html for how to use that tool.
-
wrote on 5 Apr 2012, 12:05 last edited by
Hi,
thanks for your post.
I finally managed to change the location of my library and now it loads fine.
I also used macdeployqt on my bundle. Before macdeployqt, Qt libraries were loaded from my Qt install dir and my app worked allright.
But after macdeployqt, I get this crash on startup:@Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000Application Specific Information:
objc[3696]: garbage collection is OFF
abort() calledThread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff96d1ece2 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff97d057d2 pthread_kill + 95
2 libsystem_c.dylib 0x00007fff97cf6a7a abort + 143
3 QtCore 0x00000001037b1c15 qt_message_output(QtMsgType, char const*) + 117
4 QtCore 0x00000001037b1df7 qt_message_output(QtMsgType, char const*) + 599
5 QtCore 0x00000001037b1fba qFatal(char const*, ...) + 170
6 QtGui 0x0000000102b09945 QWidgetPrivate::QWidgetPrivate(int) + 853
7 QtGui 0x0000000102b1dc7b QWidget::QWidget(QWidget*, QFlagsQt::WindowType) + 59
8 QtGui 0x0000000102a78a19 QDesktopWidget::QDesktopWidget() + 41
9 QtGui 0x0000000102ac008b QApplication::desktop() + 59
10 QtGui 0x0000000102a73dbb QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool() + 4027
11 QtGui 0x0000000102a6f4f5 QMacInputContext::reset() + 34853@Do you have any idea what's wrong?
-
wrote on 5 Apr 2012, 21:08 last edited by
Hm, strange. From the output one cannot see what's going wrong exactly. You could try to run the application from the command line and look at the console output:
/complete/path/to/your/program.app/Contents/MacOS/app_name
Do you get any warnings about libraries being loaded twice or so?
-
wrote on 5 Apr 2012, 21:50 last edited by
@$ /Users/paulfxh/QupZilla/bin/QupZilla.app/Contents/MacOS/QupZilla
QupZilla: 0 extensions loaded
QFont::setPixelSize: Pixel size <= 0 (0)
QFont::setPixelSize: Pixel size <= 0 (0)
2012-04-05 22:44:05.484 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/ebldetect.bundle/Contents/MacOS/ebldetect: dlopen(/Library/Internet Plug-Ins/ebldetect.bundle/Contents/MacOS/ebldetect, 262): no suitable image found. Did find:
/Library/Internet Plug-Ins/ebldetect.bundle/Contents/MacOS/ebldetect: no matching architecture in universal wrapper
2012-04-05 22:44:05.492 QupZilla[1404:c03] Cannot find executable for CFBundle 0x10b36e600 </Users/paulfxh/Library/Internet Plug-Ins/GlimsAddition.notplugin> (not loaded)
2012-04-05 22:44:05.613 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/npgtpo3dautoplugin.plugin/Contents/MacOS/npgtpo3dautoplugin: dlopen(/Library/Internet Plug-Ins/npgtpo3dautoplugin.plugin/Contents/MacOS/npgtpo3dautoplugin, 262): no suitable image found. Did find:
/Library/Internet Plug-Ins/npgtpo3dautoplugin.plugin/Contents/MacOS/npgtpo3dautoplugin: mach-o, but wrong architecture
2012-04-05 22:44:05.727 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/Silverlight.plugin/Contents/MacOS/agcore: dlopen(/Library/Internet Plug-Ins/Silverlight.plugin/Contents/MacOS/agcore, 262): no suitable image found. Did find:
/Library/Internet Plug-Ins/Silverlight.plugin/Contents/MacOS/agcore: mach-o, but wrong architecture
2012-04-05 22:44:05.760 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/Flip4Mac WMV Plugin.plugin/Contents/MacOS/Flip4Mac WMV Plugin: dlopen(/Library/Internet Plug-Ins/Flip4Mac WMV Plugin.plugin/Contents/MacOS/Flip4Mac WMV Plugin, 262): no suitable image found. Did find:
/Library/Internet Plug-Ins/Flip4Mac WMV Plugin.plugin/Contents/MacOS/Flip4Mac WMV Plugin: no matching architecture in universal wrapper
2012-04-05 22:44:05.851 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin: dlopen(/Library/Internet Plug-Ins/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin, 265): no suitable image found. Did find:
/Library/Internet Plug-Ins/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin: mach-o, but wrong architecture
2012-04-05 22:44:05.853 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/googletalkbrowserplugin.plugin/Contents/MacOS/googletalkbrowserplugin: dlopen(/Library/Internet Plug-Ins/googletalkbrowserplugin.plugin/Contents/MacOS/googletalkbrowserplugin, 262): no suitable image found. Did find:
/Library/Internet Plug-Ins/googletalkbrowserplugin.plugin/Contents/MacOS/googletalkbrowserplugin: mach-o, but wrong architecture
2012-04-05 22:44:06.164 QupZilla[1404:c03] Error loading /Library/Internet Plug-Ins/iPhotoPhotocast.plugin/Contents/MacOS/iPhotoPhotocast: dlopen(/Library/Internet Plug-Ins/iPhotoPhotocast.plugin/Contents/MacOS/iPhotoPhotocast, 262): no suitable image found. Did find:
/Library/Internet Plug-Ins/iPhotoPhotocast.plugin/Contents/MacOS/iPhotoPhotocast: no matching architecture in universal wrapper
@ -
wrote on 10 Apr 2012, 20:04 last edited by
Hm, strange. I don't have a clue what's going wrong here, sorry.