vc++打包发布自带依赖dll

楚天乐 342 0 条

问题

相信很多人都遇到过vx项目打包发布出去之后,用户安装运行提示缺少mfc140u.dll(数字是vc版本决定的),然而奇怪的是很少有人讨论具体怎么解决这个问题

我尝试过的办法

  1. 静态发布
    编译时候选择静态方式使用mfc,all done,打包之后的程序自带依赖

问题:
某些依赖组件只有dll,没有lib。别问我为什么,这里不做讨论。这时候就没办法使用静态方式的mfc了

  1. 安装启动vc发型包安装
    innosetup打包安装程序时候,打包vc发型包,安装过程中进行安装。
[Files]
Source: "D:\dep\mfc140u.dll"; DestDir: "{app}"; Flags: ignoreversion

[Run]
;Filename: {tmp}\vc_redist.x86.exe; Parameters: "/q /passive /Q:a /c:""msiexec /q /i vcredist.msi"""; StatusMsg: "Installing VC++ 2017 Redistributables..."

问题:

  • 装完要重启,不然找不到mfc140u.dll
  • 安装包体积大
  1. 查看dll依赖,innosetup制作安装包时候拷贝

查看依赖

> cd c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin>
> dumpbin /dependents xxx.exe

WeChat Image_20200430012314.png

加如innosetup

Source: "D:\dep\mfc140u.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\msvcp140.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-convert-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-environment-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-filesystem-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-heap-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-locale-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-math-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-multibyte-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-private-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-process-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-runtime-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-stdio-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-string-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-time-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dep\api-ms-win-crt-utility-l1-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion

完美解决,比第二种方式体积小了将近一半

打赏

微信打赏

支付宝打赏



与本文相关的文章

发表我的评论
昵称 (必填)
邮箱 (必填)
网址
执行时间: 56.939840316772 毫秒