VS2010运行结果报错error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”

来源:互联网 发布:实战最强的武术知乎 编辑:程序博客网 时间:2024/05/17 22:22

VS2010运行结果报错error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”。

1、错误原因:Debug使用了Release的库文件。
    若你连接库里两种库文件都添加着,但是却把release库文件放在了debug前面,也是会出错的。因为程序默认按顺序使用库文件。
    若报错为error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“2”不匹配值“0”。
    则可能是在release下使用了Debug的库文件。一般库文件中文件名后面加d的是debug库文件,没有加d的是release库文件。

2、解决方法:
    通过几天的查询,结合网友们的智慧,发现只需在预处理定义中设定“_ITERATOR_DEBUG_LEVEL”的值,使其符合要调试用的程序。
    在项目-〉属性-〉配置属性-〉C/C++ -〉预处理器-〉预处理定义  添加“_ITERATOR_DEBUG_LEVEL=0”即可。

3、英文补充说明:
    In VS2010 iterator debug level defaults to 2 in debug and is disabled in release. One of the dlls you are using probably has iterator debugging turned off in debug either because it was built in an older version of visual studio or they explicitly added the defines to the project.

    Search for _ITERATOR_DEBUG_LEVEL and _SECURE_SCL remove them or set them appropriately in all projects and sources and rebuild everything.

_ITERATOR_DEBUG_LEVEL = 0 // disabled (for release builds)
_ITERATOR_DEBUG_LEVEL = 1 // enabled (if _SECURE_SCL is defined)
_ITERATOR_DEBUG_LEVEL = 2 // enabled (for debug builds)

1 0
原创粉丝点击