Libjson compile and use-1. Compile

Source: Internet
Author: User

The following transfers are from: http://blog.csdn.net/laogong5i0/article/details/8212511

Recently want to use Box2dedit to edit the more complex graphics and then pour into their own game, but Box2dedit edited after the output is a JSON file.

Because there is no experience in using C + + to parse JSON files, I found a lot of open source projects about JSON on the Internet, Cjson (this is written by C) Jsoncpp (c + + project, but some people say it is not good enough) Libjson (support C and C + +) because of a sense of fear of C , so I finally chose the Libjson library.

Ok! First get the file to download down, on Google search Libjson can be found, the current latest version is libjson_7.6.1, I use this version.

Open a look, a lot of files, so directly add to our project will be very messy, so to compile into a static library.

Then start compiling the static library!!

Unzip the file just downloaded, open the Libjson.vcproj file (I use VS2010), because is. vcproj is VS2008 project file, so my vs will automatically turn into VS2010 project.

The process of conversion a little wait for 10 seconds, a open, the cup has a ~ ~ ~ ~ Error! Say there is an illegal terminator, open with. xml is really less ">" symbol, OK plus go, continue to open, or error. This is really not the god horse wrong! Then began to suspect that I am the problem of VS, OK, then I put a VS2008 on the virtual machine to try, took a lot of time (download, install this is a painful process), finally the installation is complete, quickly open Libjson. Really no words, reported the same mistake, spent so long, even project project has not opened, Libjson This library is too pit Dad!!

Since the project has no way to open, then build a project to build it!

Good!! To create a new win32project, remember to select the static library for this program type.

After the new success we will come to the library list to find 2. h files and 1. cpp files, this file is not required, we can delete it, it is in the new when we tick the precompled header generated.

Press to finish, you can compress the source files in the file into our project folder, and see, we just add the selected part of the file.

Then add it to the project we just built, such as the operation, after adding our library list will be as seen in the red box.

OK, to this we can run, run a look at it!!

Dizzy dead, a lot of wrong ~~~~~~ (this b is a garbage)

Error c1010:unexpected end of file while looking for precompiled header. Did your forget to add ' #include "StdAfx.h" ' to your source?d:\android\win32project\minigame\libjson\_internal\source\ Libjson.cpp6061libjson

He said our. cpp file forgot # include "stdafx.h" file, is this b really a garbage, human flesh "stdafx.h" (result), the principle is Win32 for the program configuration information, since it is useless things, then we can not add it, Again the human flesh of this problem, the principle in the configuration has pre-compiled settings. Right-click the project property, for example, we change the precompiled header entry to the not using precompiled headers without the precompiled header.

And then run, OH ~ There's still a mistake, okay, keep human flesh. These overview bugs,

There are some places in the JSONOptions.h file that need to be configured, there is a. pdf file in the zipped file that we downloaded, with a detailed explanation of what these options do. We need it here.

#define Json_deprecated_functions This is the major version of backward compatibility and ease of use of the excessive, do not know what is the use, but the document said this is not used, use will error, then we firmly put it out.

Because we're still in debug mode, so let's #define JSON_DEBUG on, here is the debug mode or Release mode. Comment Out is the release mode.

There is a value of # define Json_library, which is the function to use the C interface or the C + + interface. (see here you like it!) If you do not annotate the word is to use C interface, I use the C interface here)

Compile, haha success!! Although there are several caveats. Find the. lib file, incredibly after 4M more.

Next time to talk about the use of Lib!!

Next: Libjson Compile and use-2. Configure using LIB file

Libjson compile and use-1. Compile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.