1 Star 0 Fork 0

何亚红 / DeployWin

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

说明

在使用MSYS2(包括mingw)与Cygwin 上开发Windows程序,经常遇到需要打包exe所需dll问题(如动态加载的dll)。

本库主要实现自动将依赖的dll拷贝到目标exe目录:

  • 通过C++静态全局变量的构造函数启动拷贝线程。
  • 通过环境变量触发dll拷贝功能。

可不修改原有C++代码,直接将本库链接进工程即可实现dll拷贝功能。

支持的环境变量:

环境变量名称 说明
DEPLOYWIN 为1时启动dll拷贝,为其它值跳过dll拷贝
DEPLOYWIN_AUTOEXIT 当为大于0的数字时,表示自动退出的秒数。正常运行时不可设置此环境变量。通常用于CMake脚本的安装操作。

使用

  • 操作系统:Windows 7及以上

本工程主要支持CMake构建的工程,其它类型项目请直接添加src下(不包括子目录)的cpp文件。

代码示例请参考test目录,由doxygen生成的说明参考DeployWin.chm

环境变量设置

Windows Power shell

PowerShell通过env:操作环境变量:

#启用dll拷贝
$env:DEPLOYWIN=1
#关闭dll拷贝
$env:DEPLOYWIN=0

cmd

cmd中通过set命令设置环境变量:

REM 启用dll拷贝
set DEPLOYWIN=1
REM 关闭dll拷贝
set DEPLOYWIN=1

unix-like

unix-like包括msys2与cygwin,通过export导出环境变量:

#启用dll拷贝
export DEPLOYWIN=1
# 关闭dll拷贝
export DEPLOYWIN=0

测试程序截图

MSYS2 MINGW32

未启用dll拷贝:

mingw32-no-deploywin

启用dll拷贝:

mingw32-deploywin-1

mingw32-deploywin-2

mingw32-deploywin-3

MIT License Copyright (c) 2023 何亚红 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

用于MSYS2与Cygwin下的dll拷贝。 expand collapse
C++ and 3 more languages
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/HEYAHONG/DeployWin.git
git@gitee.com:HEYAHONG/DeployWin.git
HEYAHONG
DeployWin
DeployWin
master

Search