Qt 5 cannot deploy on SnowLeopard

泄露秘密 提交于 2019-12-21 04:50:49

问题


I have an issue where my app doesn't run on 10.6 Snow Leopard.

I compile with these parameters:

qmake LSPRO.pro -r -spec macx-clang CONFIG+=release CONFIG+=x86_64

in my Pro file, I have these elements:

TEMPLATE = app
HEADERS = \
    mainwindow.h \
    app_mediamanager.h \
    api.h \
    tool_htmleditor.h \
    tool_videoencoder.h \
    tool_thumbnaileditor.h
SOURCES = \
    main.cpp \
    mainwindow.cpp \
    app_mediamanager.cpp \
    api.cpp \
    tool_htmleditor.cpp \
    tool_videoencoder.cpp \
    tool_thumbnaileditor.cpp

QT += network webkitwidgets widgets concurrent sql

QMAKE_CXXFLAGS_X86_64 += -mmacosx-version-min=10.6
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6

ICON = icon.icns

RESOURCES = lspro.qrc

But even with a simple Hello world or the example files, it doesn't work...

I add the libraries with macdeployqt script. When running on 10.6 I get this as error in the report:

Dyld Error Message:
  Library not loaded: /usr/lib/libc++.1.dylib
  Referenced from: /Users/username/Desktop/LSPRO.app/Contents/MacOS/../Frameworks/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets
  Reason: image not found

The question is simple: How can I target 10.6 from a clean Qt5 in 10.8?


Update 1:

Thanks to the comments, it looks like 10.6 didn't shipped with c++11 support yet, causing the app to crash when looking for it. I tried 2 solutions:

Failed solution1 : I rebuild Qt5 with the noc++11 flag, the resulting app starts on snowleopard but fails some inner elements Videoplayer missing in Qwebkit, unable to call external binary /execute command (app crashes with EXC_BAD_ACCESS) although the binary just runs fine when called directly and probably more undiscovered.

Failed solution2 : I tried naively to include the missing dylibs (libc++.1.dylib and libc++abi.dylib) in snowleopard, but the app still crashes with the message :

Dyld Error Message:
  Symbol not found: _NSPreferredScrollerStyleDidChangeNotification
  Referenced from: /Volumes/SANS TITRE/tests/LSPRO1.app/Contents/MacOS/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets
  Expected in: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit

otool -L of a 5.1.0 rc1 build

@executable_path/../Frameworks/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtQml.framework/Versions/5/QtQml (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtOpenGL.framework/Versions/5/QtOpenGL (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.1.0, current version 5.1.0)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0)
    @executable_path/../Frameworks/QtWebKit.framework/Versions/5/QtWebKit (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtSql.framework/Versions/5/QtSql (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtSensors.framework/Versions/5/QtSensors (compatibility version 5.1.0, current version 5.1.0)
    @executable_path/../Frameworks/QtConcurrent.framework/Versions/5/QtConcurrent (compatibility version 5.1.0, current version 5.1.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

SOLUTION:

ok finally got it to work. Compiled Qt5 (5.1.2) on snowleopard from git (have xcode 4.2 with 10.6 sdk) in my case simply with these config:

./configure -developer-build -opensource -nomake examples -nomake tests -qt-sql-mysql

I had to fix small elements in my code making the app crash without reason (variable names..) and then everything was ok.

Just don't forget to use the mac deploy tool on 10.6 and the app runs ok on 10.8 (untested on 10.7 but I assume this is ok.)

Hope this helps anyone.


回答1:


The NSPreferredScrollerStyleDidChangeNotification notification is only available in OSX 10.7 and later, as noted at the bottom of this page:

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSScroller_Class/Reference/Reference.html

Qt will conditionally compile OS X 10.7 APIs if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7. See e.g.:

http://qt.gitorious.org/qt/qtbase/blobs/b9826799405293ee5969015eed37957daad198ee/src/widgets/styles/qmacstyle_mac.mm

Possibly the version of Qt you are using was not compiled with the 10.6 SDK.

There is a known issue: "To use Qt on or for 10.6, you need to build Qt yourself on a 10.6 machine":

http://qt-project.org/wiki/Qt500KnownIssues




回答2:


If you're using Qt 5.1 this is a known issue with macdeployqt, it does not correct linked library paths on the executable, you can see it by yourself with

otool -L <executable>

You can either switch back to Qt 5.1.0-rc1 or in this thread there is a workaround with a script that will fix the problem for you.




回答3:


The only way to run your application on Mac OS 10.6 with Qt 5 is to configure Qt with -no-c++ parameter. Compiling Qt on 10.6 is not an option for me, because there would be no Retina support.

The correct workaround is:

Mac OS 10.7 + Qt 5.2.0 + xcode 4.6 + configure with -no-c++11 parameter

PS. Use Vmware with 10.7 to compile Qt. Develop and deploy your app on any Mac OS X (10.9.1)



来源:https://stackoverflow.com/questions/18160966/qt-5-cannot-deploy-on-snowleopard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!