在静态库中使用MFC
我已经使用“在静态库中使用 MFC”选项创建了 MFC 应用程序。
我正在使用 Installshield 为我的应用程序创建安装。我应该在 installshield 中添加哪些依赖文件或“合并模块”?
是否需要添加“Microsoft C++ Runtime Library”或“Microsoft Visual C++ MFC”合并模块?
I have created my MFC Application with option "Use MFC in static Library".
I am creating installation for my application using Installshield. What are the dependency files or "Merge modules" should I add in the installshield?
Is it necessary to add " Microsoft C++ Runtime Library" or "Microsoft Visual C++ MFC" Merge modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
静态链接意味着 foo.lib 在链接器阶段嵌入到 myapp.exe 中。不存在对 foo.dll 的依赖,也不需要重新分发。您还应该了解,虽然静态链接使您的部署更容易,但它实际上被视为安全漏洞,因为如果在 foo.lib/foo.dll(本例中为 MFC)中发现漏洞,那么 Microsoft 无法通过更新版本来修补您的应用程序在 WinSXS 缓存中。您可以在构建机器上包含最新的 redist、重建和重新部署。
我强烈建议创建一个带有基本快照的虚拟机,该快照代表您想要支持的最旧的操作系统,然后在那里测试您的安装程序。这将有助于识别缺失的依赖项,然后可以使用 Dependency Walker、ILDasm/.NET Reflactor 和 ProcessMon 等工具来解决这些依赖项。
Static linking means the foo.lib was embedded in myapp.exe during the linker phase. No dependency on foo.dll exists and does not need to be redistributed. You should also understand that while static linking makes your deployment easier it's actually considered a security vunerability because if an exploit is found in foo.lib/foo.dll (MFC in this case) then Microsoft can't patch your application by updating the version in the WinSXS cache. It'll be up to you to include the latest redist on your build machine, rebuild and redeploy.
I highly suggest creating a virtual machine with a base snapshot that represents the oldest OS that you want to support and then testing your installer there. This will help identify missing dependencies that can then be resolved by using tools such as Dependency Walker, ILDasm/.NET Reflactor and ProcessMon.
至少如果没记错的话,没有。如果在静态库中使用 MFC,则还需要静态链接到标准库。除非您添加了对其他 DLL 的其他依赖项,否则您应该有一个独立的可执行文件。
如果您愿意,您可以/可以检查 dependency walker 来确定。
At least if memory serves, no. If you use MFC in a static library, you're also required to link statically to the standard library as well. Unless you've added some other dependency on some other DLL, you should have a standalone executable.
You can/could check with dependency walker just to be sure, if you prefer.
很多时候我们面临 exe 和 dll 的大小比以前的版本更大的问题。
这可以使用项目属性
菜单“项目” 来解决
- 特性...
配置属性--->《MFC的使用在静态库中使用MFC》
并
在“C/C++ 选项”中-->选项卡“代码生成”-->为静态 MFC 选择“多线程/MT”。
如果我们选择以上选项,那么我们不需要在PC上安装VC2008 Redistributable,并且exe或dll的大小会更小
Many times we are facing issue of size of exe and dll is more than previous build.
This can be resolved using project properties
Menu "Project"
- Properties...
Configuration Properties --->"Use of MFC Use MFC in static Library"
and
In "C/C++ options"--> tab "Code Generation"-->choose "Multithreaded /MT" for static MFC.
if we choose above options then we do not need the VC2008 Redistributable installed on the PC and size of exe or dll is lesser