本文共 1243 字,大约阅读时间需要 4 分钟。
用两台虚拟机进行测试,其中一台为QT的开发机器,另外一台没有安装QT等相关程序的部署机。
(1)将依赖的包及相应的软连接拷贝到部署机的任意目录下,并设定环境变量LD_LIBRARY_PATH,这些依赖包列表可以通过ldd命令查询 libGL.so.1.2.0、libicudata.so.51.1、libicui18n.so.51.1、libicuuc.so.51.1、libQt5Core.so.5.1.1、libQt5DBus.so.5.1.1、libQt5Gui.so.5.1.1、 libQt5Widgets.so.5.1.1和libxcb-glx.so.0.0.0 (2)无法加载插件,解决方法有如下两个 方法1: export QT_PLUGIN_PATH=/opt/Qt5.1.1/Tools/QtCreator/bin/plugins/ export LD_LIBRARY_PATH=/opt/Qt5.1.1/Tools/QtCreator/bin/plugins/platforms:$LD_LIBRARY_PATH 将开发机器上/opt/Qt5.1.1/Tools/QtCreator/bin/plugins/platforms目录及下面的文件libqxcb.so拷贝到部署机上,并设定环境变量 方法2:qt.conf加plugins [Paths] Prefix=. Plugins=plugins 在开发机器上的程序所在目录新建plugins/platforms目录,并将开发机器上/opt/Qt5.1.1/Tools/QtCreator/bin/plugins/platforms下的插件文件(libqxcb.so)拷贝过来。 均能找到插件,但仍然无法加载,提示信息如下: This application failed to start because it could not find or load the Qt platform plugin "xcb". Available platform plugins are: linuxfb, minimal, offscreen, xcb. Reinstalling the application may fix this problem. Aborted (core dumped) (3)ldd libqxcb.so 发现xcb插件依赖的libQt5DBus.so.5找不到,目前暂时无法通过方法二来手动指定目录,只能按照方法一: 将开发机/opt/Qt5.1.1/Tools/QtCreator/lib/qtcreator目录及文件libQt5DBus.so.5拷贝到部署机上相应位置。 (4)运行程序,终于调出了界面,大功告成!综上,将程序依赖的QT库文件拷贝到部署机,并设定环境变量(见(1));对于插件,将开发机的对应目录结构及必须文件拷贝到部署机上,并设定环境变量(见(2)和(3))。转载地址:http://omxvb.baihongyu.com/