Qt 5.1和Mac:使macdeployqt无法正常工作的错误 [英] Qt 5.1 and Mac: Bug making macdeployqt not working properly

查看:459
本文介绍了Qt 5.1和Mac:使macdeployqt无法正常工作的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,因为Mac OS X的Qt版本是5.1rc2.(5.1也受影响,而不是5.1rc1)
当我构建应用并在二进制文件上执行otool -L以查看共享库的路径时,我得到:(这只是一个示例,为清楚起见,我删除了其中的一些)

/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 
    (compatibility version 45.0.0, current version 1187.37.0)
/Users/chris/**Qt5.1.0//5.1.0**/clang_64/lib/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtQml.framework/Versions/5/QtQml
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui
    (compatibility version 5.1.0, current version 5.1.0)

如您所见,Qt库的路径中有一个双斜杠. 当我使用macdeployqt部署我的应用程序时,由于这些原因,这些路径不会更改为本地框架(@executable_path/../Frameworks/...). 我必须使用install_name_tool手动进行操作,这确实很烦人.

我该怎么做才能解决此问题? (我尝试过重新安装Qt,清理,再次运行qmake并进行重建,而无需进行更改)

解决方案

存在相同的问题.我应用了下一个解决方法:

构建程序后,我已将exe中的链接更改为正确的链接

install_name_tool -change /Users/username/Qt5.1.0//5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick  /Users/username/Qt5.1.0/5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick <YourExecutable>

此解决方法后,macdeployqt将exe内的所有链接更改为相对链接.

但是我的应用程序坏了.事实是,我已将所有图像和QML文件添加到资源中.运行macdeployqt之后-无法运行我的应用程序.当我与gdb一起运行时-我看到下一个错误:

QQmlApplicationEngine failed to load component 
qrc:/qml/main.qml:-1 File not found

Error: Your root item has to be a Window.

所以我所有的资源都变得不可用了.有谁知道该如何解决?

我还开始在 qt论坛

上进行讨论

更新,如何部署:

  1. 使用此脚本来消除动态链接路径中的双斜杠. /p>

    ./fixqt.sh〜/Qt5.1.0/5.1.0/clang_64

  2. 从此存储库中构建macdeployqt工具.

  3. 运行macdeployqt并使用您的qml源指定dir:

    macdeployqt MyApp.app/-qmldir = ../src/qml -dmg

完成这些步骤后,我设法在未安装QT的其他OS X系统上运行应用程序.我已将所有qml文件和图像添加到资源中.在MyApp.app/Content/MacOS/

中复制的QtQuick和QtQuick.2模块

希望有帮助

I have a problem since the version 5.1rc2 of Qt for Mac OS X. (5.1 is also affected, not the 5.1rc1)
When I build my app and do a otool -L on the binary file to see the paths of the shared libraries, I get: (it's just a sample, I removed some of them for clarity)

/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 
    (compatibility version 45.0.0, current version 1187.37.0)
/Users/chris/**Qt5.1.0//5.1.0**/clang_64/lib/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtQml.framework/Versions/5/QtQml
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtCore.framework/Versions/5/QtCore
    (compatibility version 5.1.0, current version 5.1.0)
/Users/chris/Qt5.1.0//5.1.0/clang_64/lib/QtGui.framework/Versions/5/QtGui
    (compatibility version 5.1.0, current version 5.1.0)

As you can see there is a double slash in the paths of the Qt libraries. When I use macdeployqt to deploy my app, those paths aren't changed to local frameworks (@executable_path/../Frameworks/...), because of this... I have to do it manually with the install_name_tool, and it's really annoying.

What can I do to fix this? (I've tried re-installing Qt, cleaning, runing qmake again and rebuilding without change)

解决方案

having the same issue. I applied next workaround:

after I build my program, I've changed links inside exe to a right ones

install_name_tool -change /Users/username/Qt5.1.0//5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick  /Users/username/Qt5.1.0/5.1.0/clang_64/lib/QtQuick.framework/Versions/5/QtQuick <YourExecutable>

After this workaround macdeployqt has changed all links inside exe to a relative ones.

But my App became broken. The thing is that I've added all my images and QML files into resources. After I ran macdeployqt - I can not run my app. When I ran this with gdb - I see next error:

QQmlApplicationEngine failed to load component 
qrc:/qml/main.qml:-1 File not found

Error: Your root item has to be a Window.

So somehow all my resources became unavailable. Does anyone know how to fix that?

I also started a discussion on qt forum

UPDATE, HOW TO DEPLOY:

  1. Use this script to get rid of double slashes inside dynamic linking paths.

    ./fixqt.sh ~/Qt5.1.0/5.1.0/clang_64

  2. Build macdeployqt tool from this repository.

  3. Run macdeployqt and specify dir with your qml source:

    macdeployqt MyApp.app/ -qmldir=../src/qml -dmg

After those steps I managed to run my application on different OS X system, without QT Installed. I've added all my qml files and images into resources. QtQuick and QtQuick.2 modules copied inside MyApp.app/Content/MacOS/

Hope it helps

这篇关于Qt 5.1和Mac:使macdeployqt无法正常工作的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆