我想将Qt 4.x共享库与我的应用程序一起打包,这样用户就不必安装Qt框架了。使用构建脚本,我正确修补了所有Qt依赖项,并确保不再从/Library/Frameworks
中的Qt安装中加载任何内容(请参阅我的回答here)。
但是现在我遇到了问题,因为在初始化期间的某个时刻,加载了插件/Developer/Applications/Qt/plugins/bearer/libqcorewlanbearer.dylib
:
$ export DYLD_PRINT_LIBRARIES=1
$ cd /path/to/my.app/Contents/MacOS
$ ./myappexecutable
dyld: loaded: /path/to/executable
dyld: loaded: /usr/lib/libz.1.dylib
dyld: loaded: /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia
dyld: loaded: /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
dyld: loaded: /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation
dyld: loaded: /usr/lib/libxml2.2.dylib
dyld: loaded: /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
dyld: loaded: /usr/lib/libssl.0.9.8.dylib
dyld: loaded: /System/Library/Frameworks/QTKit.framework/Versions/A/QTKit
dyld: loaded: /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtCore.framework/Versions/4/QtCore
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtGui.framework/Versions/4/QtGui
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtOpenGL.framework/Versions/4/QtOpenGL
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtWebKit.framework/Versions/4/QtWebKit
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/phonon.framework/Versions/4/phonon
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtNetwork.framework/Versions/4/QtNetwork
dyld: loaded: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
dyld: loaded: /usr/lib/libobjc.A.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
dyld: loaded: /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
dyld: loaded: /usr/lib/system/libcache.dylib
[...]
dyld: loaded: /usr/lib/libsasl2.2.dylib
dyld: loaded: /System/Library/Frameworks/AGL.framework/Versions/A/AGL
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtDBus.framework/Versions/4/QtDBus
dyld: loaded: /path/to/my.app/Contents/MacOS/./../Qt/QtXml.framework/Versions/4/QtXml
dyld: loaded: /System/Library/PrivateFrameworks/CoreServicesInternal.framework/Versions/A/CoreServicesInternal
dyld: loaded: /System/Library/Frameworks/Security.framework/PlugIns/csparser.bundle/Contents/MacOS/csparser
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ColorSync.framework/Versions/A/Resources/ColorSyncDeprecated.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
dyld: loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGXType.A.dylib
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Resources/GLEngine.bundle/GLEngine
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
dyld: loaded: /System/Library/Extensions/ATIRadeonX3000GLDriver.bundle/Contents/MacOS/ATIRadeonX3000GLDriver
dyld: loaded: /System/Library/PrivateFrameworks/GPUSupport.framework/Versions/A/Libraries/libGPUSupport.dylib
dyld: loaded: /System/Library/Extensions/AppleIntelHD3000GraphicsGLDriver.bundle/Contents/MacOS/AppleIntelHD3000GraphicsGLDriver
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Resources//GLRendererFloat.bundle/GLRendererFloat
dyld: loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libcldcpuengine.dylib
dyld: loaded: /System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/DiskImages
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreFSCache.dylib
dyld: loaded: /System/Library/Frameworks/DiscRecording.framework/Versions/A/DiscRecording
dyld: loaded: /usr/lib/libcurl.4.dylib
dyld: loaded: /System/Library/PrivateFrameworks/MediaKit.framework/Versions/A/MediaKit
dyld: loaded: /Developer/Applications/Qt/plugins/bearer/libqcorewlanbearer.dylib
[^^^ this one is problematic as it loads global Qt libraries, see below]
dyld: loaded: /System/Library/Frameworks/CoreWLAN.framework/Versions/A/CoreWLAN
dyld: loaded: /Library/Frameworks/QtNetwork.framework/Versions/4/QtNetwork
dyld: loaded: /Library/Frameworks/QtCore.framework/Versions/4/QtCore
QObject::moveToThread: Current thread (0x7fc2d260b280) is not the object's thread (0x7fc2d4245fd0).
Cannot move to target thread (0x7fc2d260b280)
该插件引用了全局安装的Qt框架,然后我基本上加载了两组Qt二进制文件,造成各种麻烦。
现在我的问题是:该插件在哪里加载(找不到包含“wlanbearer”的任何二进制文件),我如何确保没有从我的应用程序自动加载插件?
答案 0 :(得分:0)
尝试在QApplication初始化后立即替换插件路径:
QApplication app(argc, argv);
QCoreApplication::removeLibraryPath(QLibraryInfo::location(QLibraryInfo::PluginsPath));
QCoreApplication::addLibraryPath("../../PlugIns");
它对我有用。