本文介绍了Visual Studio链接器警告LNK4098的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个dll项目,在发布配置中构建该项目时,出现以下警告:

I have a dll project in which, when in Release configuration I build the project, I get the following warning:

这只是一个警告,但我不知道是否应该考虑到这一点.

It's just a warning but I dunno if this should be taken into account.

对于我发现的东西,它们都是多线程库,普通版本和调试版本.我的dll使用多线程,并且可以调试它,尽管我使用boost:thread进行调试,所以如果需要此Windows特定库进行调试或发布版本,我真的不知道.

For what I've found out, they are both multithread libs, normal and debugging versions. My dll uses multithreading and I can debug it, although I use boost:thread for it, so I really dunno if I need this Windows specific libraries for debugging or Release building...

亲切的问候,亚历克斯

Kind regards,Alex

好吧,我按照BuschnicK的建议进行了操作,并使用/VERBOSE:LIB链接器标志,发现我已在Debug配置中链接到这些库:

Well, I did as BuschnicK suggested and using the /VERBOSE:LIB linker flag I found out that I was linking to these libraries in Debug configuration:

boost_filesystem-vc100-mt-gd-1_44.lib:libboost_system-vc100-mt-gd-1_44.lib:libboost_thread-vc100-mt-gd-1_44.lib:libboost_date_time-vc100-mt-gd-1_44.lib:

boost_filesystem-vc100-mt-gd-1_44.lib:libboost_system-vc100-mt-gd-1_44.lib:libboost_thread-vc100-mt-gd-1_44.lib:libboost_date_time-vc100-mt-gd-1_44.lib:

我在Release config中具有相同的功能,主要是因为我没有明确地"指定.因此,我在Release中将其更改为此:

I had the same in Release config, mostly because I didn't specify then "explicitly". Thus, I changed them to this in Release:

boost_filesystem-vc100-mt-1_44.lib:libboost_system-vc100-mt-1_44.lib:libboost_thread-vc100-mt-1_44.lib:libboost_date_time-vc100-mt-1_44.lib:

boost_filesystem-vc100-mt-1_44.lib:libboost_system-vc100-mt-1_44.lib:libboost_thread-vc100-mt-1_44.lib:libboost_date_time-vc100-mt-1_44.lib:

这似乎可行,但我仍然收到第一个警告,直到我意识到我的Release配置中也有_DEBUG预处理程序定义,将其删除后,它现在可以正常工作了.

That seem to worked but I was still getting the first warning, til I realized I had the _DEBUG preprocessor definition in my Release config too, removed it and it's working sweet now.

感谢大家的帮助!

推荐答案

听起来您可以在同一版本中运行调试库和发行版编译库.

It sounds like you could be running a debug library and a release compiled library in the same build.

浏览项目选项,然后选择使用所使用的任何第三方库的调试版本.

Go through your project options and select to use the debug versions of any 3rd party libraries you use.

这篇关于Visual Studio链接器警告LNK4098的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:01