mynameisalon
mynameisalon

Reputation: 165

Problem compiling libjson in "Release" configuration with VS2010

I downloaded the libjson package and added it to my VS2010 projects folder. I created a new project called checkJson and added the following code:

#include "../../libjson/libjson.h"
int main(){ return 0;}

When I compile I get an error : "Release build of libjson, but NDEBUG is not on"

Since this is the first time I am using Visual Studio I think I have very basic mistake here. Can you help me please ?

Moreover, if there is a problem with this package, or if you know some other json parsing packages that I could use without lots of configuration issues I don't care using them instead of this package.

Upvotes: 4

Views: 3412

Answers (4)

wangj
wangj

Reputation: 11

Add JSON_DEBUG to the preprocessor settings can save you. but I meet another error msg:

error C2059: syntax error : ''  

and

//#define JSON_DEPRECATED_FUNCTIONS 

Upvotes: 1

Captain Obvlious
Captain Obvlious

Reputation: 20063

Visual Studio will add the NDEBUG directive to the preprocessor settings of a project when it is created. It's possible that somewhere along the line this was removed or changed. Go into the project properties and select the appropriate configuration (in this case "Release"). Then go into Configuration Properties -> C/C++ -> Preprocessor. At the top you will see Preprocessor Directives. In this property make sure that NDEBUG is present. If not add it. Note that this property will contain multiple preprocessor definitions each separated by a semi-colon. For instance, in a 32 bit Windows console application you will see something like this -

WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions).

Do not add #define NDEBUG to any header or source file in your project unless you absolutely know what you are doing. If you do not wrap it with the appropriate #ifdef/#endif directives this can cause issues with non-release builds.

Upvotes: 1

Slartibartfast
Slartibartfast

Reputation: 1

Is there a warning like "Warning C4603: 'NDEBUG' : macro is not defined or definition is different after precompiled header".?

If yes, than just place the #define NDEBUG AFTER the #include "stdafx.h" or move it into stdafx.h

I had also to comment the line #define JSON_DEPRECATED_FUNCTIONS in JSONOptions.h, but after that i was at least able to compile.

Upvotes: 0

Benoît
Benoît

Reputation: 16994

For starters, try compiling your project in "Release" configuration.

If it works (and i believe it should), you may try and define the NDEBUG variable even in debug configuration. But it may yield unexpected results !

Upvotes: 1

Related Questions