Compiling jsoncpp libraries and issues to be aware of
Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="color: #ff0000;"><strong>Original articles, Reproduced please specify the original author and the text of this article Url.</strong></span></p></p><p><p><br><strong>Version:</strong><br>Jsoncpp-src-0.5.0.zip<br><strong>Brief introduction:</strong><br>Jsoncpp is a JSON library implemented with cpp, which can assemble, parse, and generate JSON strings.<br>We're going to compile him into a dynamic library.<br>This library uses scons to organize projects and to compile with python instead of the makefile that I am familiar with.<br>The files to be compiled are all located in./src/lib_json, in fact, 3. cpp Files.<br>In order to compile conveniently, I wrote the makefile as Follows:</p></p><pre><pre>g++ Json_reader. <span style="color: #0000ff;">CPP</span> Json_value. <span style="color: #0000ff;">CPP</span> Json_writer. <span style="color: #0000ff;">CPP</span> -fpic-wall-shared-o.. /.. /build/x64/release/libjson.so-i. /.. /include-i.</pre></pre><p><p><strong>To compile the Windows Version:</strong></p></p><p><p>When compiling windows, you need to build your own project, I use the vs2010, generate a dynamic library to remember the predefined export macros, json_dll_build, so that the DLL to export the interface class.<br>The classes exported in Config.h are defined like this: <span class="cnblogs_code">define JSON_API __declspec (dllexport)</span><br><br><strong>Issues that are noted in compiling Windows Edition:</strong><br>There is an episode between this, like the following code:</p></p><pre><pre><span style="color: #0000ff;">int</span> Main (<span style="color: #0000ff;">int</span> argc,<span style="color: #0000ff;">Char</span>*<span style="color: #000000;"> argv[]) { json::reader Reader; </span> <span style="color: #0000ff;">return</span> <span style="color: #800080;">0</span> <span style="color: #000000;">;}</span></pre></pre><p><p>Actually in the destruction of the reader when the crash, and the Linux version is completely no problem ah, it seems that the compilation of the library has a problem.<br>finally, The reason is that when using vs compile, the "configuration type" of the project configuration is changed into a dynamic library, so the dynamic library is Problematic.<br><strong>Workaround:</strong><br>Re-establish a dynamic library project, re-add the source code, compile, and then you can use the Normal.<br>The size of this generated library is much smaller than the old one, and it does look different.<br><strong>Summarize:</strong><br>Use vs to build dynamic library, Use the wizard to set up the dynamic library project, but can not simply change the "configuration type" to the dynamic library, otherwise, Although the compilation is not a problem, but the operation will be Problematic.<br><br><span style="color: #ff0000;"><strong>Original articles, Reproduced please specify the original author and the text of this article Url.</strong></span><br><br></p></p><p><p>Compiling jsoncpp libraries and issues to be aware of</p></p></span>
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