怎样建立微网站,wordpress 导航网站模板,建网站公司专业,仿简书wordpress博客主题Qt 5.7.0 编写的程序需要部署到一台没有安装Qt的目标机器上#xff0c;程序采用C与QML混合编程#xff0c;QML做界面#xff0c;C写逻辑。
环境说明 开发环境 Ubuntu 16.04.1 LTS 运行环境 CentOS 7.2.1511 下面描述这个手工操作的发布过程。
1、在开发环境中采用Re…Qt 5.7.0 编写的程序需要部署到一台没有安装Qt的目标机器上程序采用C与QML混合编程QML做界面C写逻辑。
环境说明 开发环境 Ubuntu 16.04.1 LTS 运行环境 CentOS 7.2.1511 下面描述这个手工操作的发布过程。
1、在开发环境中采用Release方式编译程序生成执行程序qtest 2、在目标环境中从开发环境拷贝执行程序并尝试执行./qtest 报错error while loading shared libraries: libQt5Quick.so.5: cannot open shared object file: No such file or directory 解决从开发环境中拷贝需要的动态库文件放在与执行程序相同的路径下并设置环境变量LD_LIBRARY_PATH export LD_LIBRARY_PATH.:$LD_LIBRARY_PATH 再次执行./qtest 3、运行时还会提示其他的动态库文件缺失根据提示再次拷贝相应的文件 可以在开发环境中使用ldd命令查看执行程序依赖的Qt动态库文件ldd qtest | grep libQt打包拷贝。
4、再次执行报错 This application failed to start because it could not find or load the Qt platform plugin xcb in . 解决在执行程序所在的当前路径下创建子目录并从开发环境中Qt安装目录下的plugins子目录中拷贝动态库文件
mkdir platforms
scp 开发环境:/path_to_Qt/plugins/platforms/libqxcb.so platforms/
重要!!! 根据ldd libqxcb.so的输出拷贝需要的几个库文件如libQt5DBus.so.5 libQt5XcbQpa.so.5放在与执行程序相同的路径下 5、再次执行报错 qrc:/main.qml:1:1: module QtQuick is not installed qrc:/main.qml:4:1: module QtQuick.Controls is not installed qrc:/main.qml:3:1: module QtQuick.Window is not installed qrc:/main.qml:2:1: module QtQuick.Layouts is not installed ... 解决从开发环境中拷贝Qt安装目录下的qml子目录并设置环境变量
scp -rp 开发环境:/path_to_Qt/qml ./ export QML2_IMPORT_PATH./qml 6、再次执行报错 qrc:/main.qml:4:1: plugin cannot be loaded for module QtQuick.Controls: Cannot load library qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so: (libQt5QuickTemplates2.so.5: cannot open shared object file: No such file or directory) qrc:/main.qml:4:1: plugin cannot be loaded for module QtQuick.Controls: Cannot load library qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so: (libQt5QuickControls2.so.5: cannot open shared object file: No such file or directory) qrc:/main.qml:3:1: plugin cannot be loaded for module QtQuick.Controls: Cannot load library qml/QtQuick/Controls/libqtquickcontrolsplugin.so: (libQt5Widgets.so.5: cannot open shared object file: No such file or directory) 解决根据提示从开发环境拷贝缺失的动态库文件
7、再次执行报错 qrc:/main.qml:14:5: QML Image: Error decoding: qrc:/png/1/back.jpg: Unsupported image format 解决从开发环境中拷贝图像格式解析插件 mkdir imageformats
scp 开发环境:/path_to_Qt/plugins/imageformats/libqjpeg.so imageformats/ 8、再次执行报错 QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled failed to acquire GL context to resolve capabilities, using defaults.. QXcbConnection: XCB error: 147 (Unknown), sequence: 171, resource id: 0, major code: 140 (Unknown), minor code: 20 QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 1, profile 0)
解决从开发环境中拷贝所需的glx/egl插件 mkdir xcbglintegrations
scp 开发环境:/path_to_Qt/plugins/xcbglintegrations/libqxcb-egl-integration.so xcbglintegrations
scp 开发环境:/path_to_Qt/plugins/xcbglintegrations/libqxcb-glx-integration.so xcbglintegrations
9、搞定
总结 目标环境需要四类文件
1、一组动态库文件放在执行程序所在目录下
2、一组插件放在执行程序所在目录下的子目录中
3、一个qml子目录
4、两个环境变量LD_LIBRARY_PATH QML2_IMPORT_PATH ———————————————— 版权声明本文为CSDN博主「justkk」的原创文章遵循CC 4.0 BY-SA版权协议转载请附上原文出处链接及本声明。 原文链接https://blog.csdn.net/justkk/article/details/52921899