首页 > 其他 > 详细

强制加载库

时间:2015-11-08 14:03:51      阅读:279      评论:0      收藏:0      [点我收藏+]

VC中,如果隐式链接的lib或dll未被引用,编译器并不会去生成加载该lib或dll的代码,从VLD1.0版本中看到可以通过如下方式强制引用:

// Force a symbolic reference to the global VisualLeakDetector class object from
// the library. This enusres that the object is linked with the program, even
// though nobody directly references it outside of the library.
#pragma comment(linker, "/include:?visualleakdetector@@3VVisualLeakDetector@@A")

其中,“?visualleakdetector@@3VVisualLeakDetector@@A”即vldmtdll.lib中VisualLeakDetector类的构造函数,

通过dumpbin /SYMBOLS vldmtdll.lib 可以看到

强制加载库

原文:http://www.cnblogs.com/through/p/4946328.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!