Danikaze
Danikaze

Reputation: 193

Using #define NDEBUG give me errors in C++

If I define NDEBUG in the top of my main.cpp I get all this errors:

1>  All outputs are up-to-date.
1>libcmt.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invalid_parameter@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler already defined in LIBCMTD.lib(invarg.obj)
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

I'm using MS Visual Studio 2010, boost and gosu libs.

Upvotes: 0

Views: 927

Answers (2)

Björn Pollex
Björn Pollex

Reputation: 76828

This most likely occurs due to a mismatch between included headers (which will be release version if you define NDEBUG) and linked libraries, which appear to be debug-versions. Maybe some of the headers rely on auto-linking features, and thus you get different versions of a library linked.

Upvotes: 1

Puppy
Puppy

Reputation: 146940

This is because MSVC already defines NDEBUG for you in Release build. You shouldn't #define _DEBUG or #define NDEBUG yourself, use the pre-provided #defines.

Upvotes: 0

Related Questions