Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsoncpp compilation error #1

Closed
jianSG opened this issue Sep 10, 2018 · 2 comments
Closed

jsoncpp compilation error #1

jianSG opened this issue Sep 10, 2018 · 2 comments

Comments

@jianSG
Copy link

jianSG commented Sep 10, 2018

I ran into following error when compiling jsoncpp. jsoncpp Github page suggests it may related to gcc/g++ version and/or standard, but I do not understand the way to solve it in the context of THUNDER.
I am using gcc/g++ 7.3 on Ubuntu 18.04 LTS, cuda 9.1. Thanks for your help in advance.


[ 71%] Linking CXX static library libcore.a
[ 71%] Built target core
Scanning dependencies of target jsoncpp
[ 72%] Building CXX object external/jsoncpp/CMakeFiles/jsoncpp.dir/jsoncpp.cpp.o
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:234:14: error: ‘scoped_ptr’ in namespace ‘std’ does not name a template type
typedef std::scoped_ptr const CharReaderPtr;
^~~~~~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp: In function ‘bool Json::parseFromStream(const Json::CharReader::Factory&, std::istream&, Json::Value*, std::__cxx11::string*)’:
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:2007:3: error: ‘CharReaderPtr’ was not declared in this scope
CharReaderPtr const reader(fact.newCharReader());
^~~~~~~~~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:2007:3: note: suggested alternative: ‘CharReader’
CharReaderPtr const reader(fact.newCharReader());
^~~~~~~~~~~~~
CharReader
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:2008:10: error: ‘reader’ was not declared in this scope
return reader->parse(begin, end, root, errs);
^~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:2008:10: note: suggested alternative: ‘Reader’
return reader->parse(begin, end, root, errs);
^~~~~~
Reader
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp: At global scope:
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:3803:14: error: ‘scoped_ptr’ in namespace ‘std’ does not name a template type
typedef std::scoped_ptr const StreamWriterPtr;
^~~~~~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp: In function ‘std::__cxx11::string Json::writeString(const Json::StreamWriter::Factory&, const Json::Value&)’:
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4924:3: error: ‘StreamWriterPtr’ was not declared in this scope
StreamWriterPtr const writer(builder.newStreamWriter());
^~~~~~~~~~~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4924:3: note: suggested alternative: ‘StreamWriter’
StreamWriterPtr const writer(builder.newStreamWriter());
^~~~~~~~~~~~~~~
StreamWriter
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4925:3: error: ‘writer’ was not declared in this scope
writer->write(root, &sout);
^~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4925:3: note: suggested alternative: ‘Writer’
writer->write(root, &sout);
^~~~~~
Writer
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp: In function ‘std::ostream& Json::operator<<(std::ostream&, const Json::Value&)’:
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4931:3: error: ‘StreamWriterPtr’ was not declared in this scope
StreamWriterPtr const writer(builder.newStreamWriter());
^~~~~~~~~~~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4931:3: note: suggested alternative: ‘StreamWriter’
StreamWriterPtr const writer(builder.newStreamWriter());
^~~~~~~~~~~~~~~
StreamWriter
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4932:3: error: ‘writer’ was not declared in this scope
writer->write(root, &sout);
^~~~~~
/home/jianshi/Downloads/THUNDER-master/external/jsoncpp/jsoncpp.cpp:4932:3: note: suggested alternative: ‘Writer’
writer->write(root, &sout);
^~~~~~
Writer
external/jsoncpp/CMakeFiles/jsoncpp.dir/build.make:62: recipe for target 'external/jsoncpp/CMakeFiles/jsoncpp.dir/jsoncpp.cpp.o' failed
make[2]: *** [external/jsoncpp/CMakeFiles/jsoncpp.dir/jsoncpp.cpp.o] Error 1
CMakeFiles/Makefile2:588: recipe for target 'external/jsoncpp/CMakeFiles/jsoncpp.dir/all' failed
make[1]: *** [external/jsoncpp/CMakeFiles/jsoncpp.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

@paradoxstar
Copy link
Contributor

It is caused by the version of gcc/g++.
Since there are the selections of CharReaderPtr in jsoncpp.cpp as below:
233 #if __GNC__ >= 6
234 typedef std::scoped_ptr<CharReader> const CharReaderPtr;
235 #else
236 typedef std::auto_ptr<CharReader> CharReaderPtr
237 #endif
For better compatibility to clusters with old version compilers(gcc/g++ 4.x, usually using these versions for stability), THUNDER does not use c++11 standard library (without '-std=c++11'), and we only test on gcc/g++4.x, 5.x, which make the selection to be std::auto_ptr<CharReader>.
Under your condition(gcc/g++ 7.3),it may select std::scoped_ptr<CharReader> . So c++11 standard library is necessary.

There are two solutions:

  1. You can easily comment this selection, like:
    233 //#if __GNC__ >= 6
    234 //typedef std::scoped_ptr<CharReader> const CharReaderPtr;
    235 //#else
    236 typedef std::auto_ptr<CharReader> CharReaderPtr
    237 //#endif
  2. You can add the c++11 standard library in cmake:
    cmake -DADDITIONAL_FLAGS="-std=c++11" ..

We will fix this bug soon. :)

@jianSG
Copy link
Author

jianSG commented Sep 12, 2018

Great. By comment off the lines actually worked. Thanks a lot for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants