I have read a lot of solutions to my problem but none helped. I tried clean, rebuild. Reinstalled visual 2010 and change from professional to ultimate. But still I dont know
I make a little update on this issue, as I just had the same error today on an application which is linking against a static lib, after I migrated the old Visual 6 project to Visual Studio 2012.
In my case the error was that I mistakenly compiled the Release version of the static lib with /MDd instead of /MD, whereas the application is /MD in release. Setting the correct /MD in the static lib project solved the issue.
This is done in Project properties
Like all the other answers, I checked my Configuration Properties -> C/C++ -> Preprocessor
directives.
In my case I had the NDEBUG
correctly defined in Release, but I also had: _SECURE_SCL=1
.
Removing that one fixed the issue.
I had a mismatch between projects: one with multi-byte character set, the other with Unicode. Correcting these to agree on Unicode corrected the problem.
In my case the NDEBUG macro definition in the "Preprocessor Definitions" needed to be changed to _DEBUG. I am building a static library for use in a .exe which was complaining about the very same error listed in the question. Go to Configuration Properties ("Project" menu, "Properties" menu item) and then click the C/C++, section, then the Preprocessor section under that, and then edit your Preprocessor Definitions so that NDEBUG is changed to _DEBUG (to match the setting in the exe).
I had this problem as well.
My problem was that I had copy/pasted the library include directories from my debug configurations.
So project "Indep" was including static library "Dep.lib" from "../Debug", even in release. The fix was to change the library directory to "../Release" so I caught the release-built library rather than the previously-built debug library.
If you would like to purposely link your project A in Release against another project B in Debug, say to keep the overall performance benefits of your application while debugging, then you will likely hit this error. You can fix this by temporarily modifying the preprocessor flags of project B to disable iterator debugging (and make it match project A):
In Project B's "Debug" properties, Configuration Properties -> C/C++ -> Preprocessor, add the following to Preprocessor Definitions:
_HAS_ITERATOR_DEBUGGING=0;_ITERATOR_DEBUG_LEVEL=0;
Rebuild project B in Debug, then build project A in Release and it should link correctly.