使用 Qt 5、C++ 和 OpenCV 从 Linux 创建可执行文件
Create Executable from Linux using Qt 5, C++ and OpenCV
我一直在尝试部署我的程序的可执行版本,我尝试了很多方法,如
- 运行它处于释放模式
- linuxdeployqt工具
- GitHub + 詹金斯
但那些对我不起作用,我可以在开发环境中部署该程序,但我需要在不同的计算机上安装它。如果可以为 Windows 创建版本(因为我开发它的大学要求它)
我正在使用 Qt 5.9.5、gcc 7.5.0、CMake 3.10.2、GDB 8.1.0、OpenCV 4.1.1 和 SO Linux Mint 19.1 Tessa。
我建议您尝试使用 https://github.com/QuasarApp/CQtDeployer
中的 CQtDeployer
您可以在 this video 中找到安装指南,尽管它不是英文的,但里面的所有内容都在逐步说明。
希望对你有用。
如何使用 cqtdeployer 部署项目。
第一个你需要安装 cqtdeployer 到你的平台
- Snap(另外 14 个 linux 分布):
sudo snap install cqtdeployer
或
从快照存储安装并添加所有要求的权限。
- 其他linuxLinuxInstaller.run.
chmod +x LinuxInstaller.run
./LinuxInstaller.run
- Windows installer
在发布模式下构建项目。
部署您的可执行文件。
- 对于 Linux 系统:
cqtdeployer -bin myexecutable
- 对于 Windows 系统:
cqtdeployer -bin myexecutable.exe -qmake C:/Qt/5.15.0/min_gw/bin/qmake.exe
- 对于跨平台构建(Linux -> Windows)
cqtdeployer -bin myexecutable.exe -qmake ~/crossbuildet-Qt/5.15.0/min_gw/bin/qmake
额外选项
如果你使用额外的库。只需将 cqtdeployer 的路径添加到使用的库。
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs
如果您想从 libDir 路径递归查找库,只需添加 recursiveDepth 选项。
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5
如果您的应用程序使用 qml,只需添加 qmlDir 选项
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources
如果您想为您的应用程序创建简单的安装程序,只需添加 qif 选项。
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources qif
如果您使用系统 PATH 中的系统库,只需添加 deploySystem 选项。
警告:快照版本没有系统文件权限。要部署系统库,请使用 installer 中的 cqtdeployer 版本
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources qif deploySystem
如果您在使用 cqtdeployer 时遇到任何问题,请在官方 github issues page.
上向您提问
有关 CQtDeploye 的更多选项,请参阅官方 documentation。
我一直在尝试部署我的程序的可执行版本,我尝试了很多方法,如
- 运行它处于释放模式
- linuxdeployqt工具
- GitHub + 詹金斯
但那些对我不起作用,我可以在开发环境中部署该程序,但我需要在不同的计算机上安装它。如果可以为 Windows 创建版本(因为我开发它的大学要求它)
我正在使用 Qt 5.9.5、gcc 7.5.0、CMake 3.10.2、GDB 8.1.0、OpenCV 4.1.1 和 SO Linux Mint 19.1 Tessa。
我建议您尝试使用 https://github.com/QuasarApp/CQtDeployer
中的 CQtDeployer您可以在 this video 中找到安装指南,尽管它不是英文的,但里面的所有内容都在逐步说明。
希望对你有用。
如何使用 cqtdeployer 部署项目。
第一个你需要安装 cqtdeployer 到你的平台
- Snap(另外 14 个 linux 分布):
sudo snap install cqtdeployer
或
从快照存储安装并添加所有要求的权限。
- 其他linuxLinuxInstaller.run.
chmod +x LinuxInstaller.run ./LinuxInstaller.run
- Windows installer
在发布模式下构建项目。
部署您的可执行文件。
- 对于 Linux 系统:
cqtdeployer -bin myexecutable
- 对于 Windows 系统:
cqtdeployer -bin myexecutable.exe -qmake C:/Qt/5.15.0/min_gw/bin/qmake.exe
- 对于跨平台构建(Linux -> Windows)
cqtdeployer -bin myexecutable.exe -qmake ~/crossbuildet-Qt/5.15.0/min_gw/bin/qmake
额外选项
如果你使用额外的库。只需将 cqtdeployer 的路径添加到使用的库。
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs
如果您想从 libDir 路径递归查找库,只需添加 recursiveDepth 选项。
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5
如果您的应用程序使用 qml,只需添加 qmlDir 选项
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources
如果您想为您的应用程序创建简单的安装程序,只需添加 qif 选项。
cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources qif
如果您使用系统 PATH 中的系统库,只需添加 deploySystem 选项。
警告:快照版本没有系统文件权限。要部署系统库,请使用 installer 中的 cqtdeployer 版本cqtdeployer -bin myexecutable -libDir /PathToMyExtraLibs -recursiveDepth 5 -qmlDir /path/to/my/qml/sources qif deploySystem