写了点qt界面程序,然而发现很难移植到其他没有安装qt环境的电脑上运行。查资料了解到,在windows上有windowsdeployqt程序,linux上有linuxdeployqt可以帮助我们快速打包。
1. 配置qt环境
首先,我们先把qt环境配置好,在~/.bashrc中加入:
export path=/home/xl/qt5.9.2/5.9.2/gcc_64/bin:$path
export ld_library_path=/home/xl/qt5.9.2/5.9.2/gcc_64/lib:$ld_library_path
export qt_plugin_path=/home/xl/qt5.9.2/5.9.2/gcc_64/plugins:$qt_plugin_path
export qml2_import_path=/home/xl/qt5.9.2/5.9.2/gcc_64/qml:$qml2_import_path
其中/home/xl/qt5.9.2/5.9.2/目录要根据自己电脑上安装的qt路径进行修改。
然后执行sourec ~/.bashrc使配置生效。
2. 编译linuxdeployqt
项目地址: 。
虽然有放出编译好的包,但是由于我使用的是ubuntu18, 系统版本过高,因此还是选择编译代码的方式。
为了避免编译好的包运行时检测到我们的系统版本过高,不继续执行的问题,我们编译前,将tools/linuxdeployqt/main.cpp中的下述代码注释掉:
// opensuse leap 15.0 uses glibc 2.26 and is used on obs
/*if (strvers