【提问】怎么解决LINK : warning LNK4089: all references to "OLEAUT32.dll" discarded by /OPT:REF

zhuweiping2003 2009-04-27 01:55:59
如题。
在debug时候没有错误和警告
在release的时候就出现了上述的警告。

请问是程序问题还是编译器设置问题。

附:运行环境 windows XP , VC++6.0
...全文
896 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuweiping2003 2009-04-28
  • 打赏
  • 举报
回复
参看:
What does Link warning LNK4089 mean, and how can I avoid it?

What does Link war This warning simply means that you are linking against a library and the linker has detected that you are not really using any functions from it. This warning usually only pops when you are making release builds, because the /OPT:REF switch of the linker that's set by default on release builds asks the linker to trim your resulting executable as much possible by avoiding linking unnecessary dlls in. (this makes the import address table of your executable much smaller).

If you don't care about the warning, you can tell the linker to ignore it by adding the /IGNORE:4089 switch to the linker command line from the Project->Settings dialog
zhuweiping2003 2009-04-28
  • 打赏
  • 举报
回复
自己贴出自己的理解:

warning LNK4089: all references to "****.dll" discarded by /OPT:REF
开发平台:VC
出现错误:
warning LNK4089: all references to "USER32.dll" discarded by /OPT:REF。
错误原因:
由于打开了优化选项,而且程序中包含或加入了USER32.dll,但是却没有调用该库中的任何函数或方法, 所以系统给个通知。
解决办法:
a)这个问题一般出现在release版中,当release版编译时会对代码进行优化,将程序中实际上并没用到的,而在工程中链接了的库放弃而不编译到工程中去。可在工程设置中的Link中的input中ingore libraries中将该库的lib文件名输入。
b)不予理会,因为它不会影响程序。
C)如果不想显示这个提示,可以在project->settings->linking->projects options中加上/OPT:NOREF
或者 #pragma comment(linker, "/ignore:4089") 取消警告
FengRider 2009-04-27
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 hairetz 的回复:]
警告不用管他
就是在编译release版的时候,是会把没有链接到的东西都“丢弃”的
解决方法就是disable眼不见为净了^_^
#progma warning(disable: 4089)
[/Quote]
4楼正解。release把一些不用的东西全部丢弃了,编译器只是提示你丢弃了哪些没用的东西。如果不想看见可以用4楼的办法,或者在项目-》工程属性-》链接器-》命令行里面输入/ignore:4089,然后保存即可。
nwao7890 2009-04-27
  • 打赏
  • 举报
回复
是你include进来的头文件中有些根本没有用到,系统自动帮你去掉了,这个警告没有关系的,不影响程序。
  • 打赏
  • 举报
回复
警告不用管他
就是在编译release版的时候,是会把没有链接到的东西都“丢弃”的

解决方法就是disable眼不见为净了^_^

#progma warning(disable: 4089)
  • 打赏
  • 举报
回复
http://topic.csdn.net/t/20031020/11/2374068.html
cyldf 2009-04-27
  • 打赏
  • 举报
回复
没遇到过,帮顶~~

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧