VS2010 Build MFC always links gdiplus.dll

来源:互联网 发布:英灵召唤师 知乎 编辑:程序博客网 时间:2024/05/17 22:32

在使用VS2010编译MFC程序的时候(以静态MFC的方式包含),发现程序会自动将gdiplus.dll链接到生成的exe文件中,即使你没有使用gdiplus中的任何函数。

使用VS2008编译同样的程序,也会有gdiplus.dll链接到exe文件中,分析一下程序,是因为CDialogEx这个对话框的基类引起的,原因是CDialogEx中引入了一些对窗口进行特殊处理的方法,可能使用了gdiplus中的函数。将CDialogEx改为CDialog后,在VS2008下编译程序,查看exe就没有gdiplus.dll的链接了。

以同样的方法对VS2010中的MFC程序进行修改,结果仍然包含gdiplus.dll的链接。

下面是Windows C++组对这个问题的回复:

 

由 Microsoft 在 2010/7/23 13:31 发送
Hello,

Thanks for the report. This is by design. MFC uses the ATL CImage class internally, which depends on GDIPlus to be able to draw PNG images.

Pat Brenner
Visual C++ Libraries Development

 

最终的原因是因为MFC中的类CImage使用了GDIPlus的相关方法(主要是用于PNG图片的绘制)导致的。

 

由 Microsoft 在 2010/8/4 11:55 发送
Hi,
You didn't see gdiplus.dll in your application when you use dynamic mfc because mfc100*.dll but not your application depends on gdiplus.dll. If open expand mfc100*.dll, you can see gdiplus.dll there.
When you static link to mfc, then mfc is part of your application, so you will see gdiplus.dll under your application.
Thanks,
Windows C++ Team

 

所以使用动态MFC链接方式编译的话就不会有gdiplus.dll的链接,是因为mfc100*.dll包含了gdiplus.dll的链接,原因就是出在MFC的底层类库。

最后,Microsoft的答复是他们正在处理。希望能在下一次的补丁中看到相关修改吧!


HITZZL

2010年12月30日

原创粉丝点击