Compiler error - Ubuntu 16.04
I'm getting this error while compiling OSVR from source following this guide. On make, I get this:
In file included from /home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp:33:0:
/usr/local/include/json/writer.h:352:45: error: ‘PrecisionType’ is not a class or namespace
PrecisionType precisionType = PrecisionType::significantDigits);
OS: Ubuntu 16.04 cmake: version 3.13.0-rc3 Compiler: GNU 5.4.0
Can you run make VERBOSE=1 and paste the compiler command as well? I want to make sure that it's compiling with -std=c++11 (or newer).
Here is the result for make VERBOSE=1 I also included the result for the whole command as a log file.
It doesn't seem like it's compiling with -std=c++11. Should I add the flag myself?
cd /home/isir/Documents/OSVR-Core/build/devtools && /usr/bin/c++ -isystem /usr/local/include -O2 -g -DNDEBUG -o CMakeFiles/osvr_json_to_c.dir/osvr_json_to_c.cpp.o -c /home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp
In file included from /home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp:33:0:
/usr/local/include/json/writer.h:352:45: error: ‘PrecisionType’ is not a class or namespace
PrecisionType precisionType = PrecisionType::significantDigits);
^
/home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp: In function ‘void convertJsonToLiteral(const string&, std::istream&, std::ostream&)’:
/home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp:65:18: warning: ‘Json::Reader::Reader()’ is deprecated: Use CharReader and CharReaderBuilder instead [-Wdeprecated-declarations]
Json::Reader reader;
^
In file included from /home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp:32:0:
/usr/local/include/json/reader.h:56:3: note: declared here
Reader();
^
/home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp:72:22: warning: ‘FastWriter’ is deprecated: Use StreamWriterBuilder instead [-Wdeprecated-declarations]
Json::FastWriter writer;
^
In file included from /home/isir/Documents/OSVR-Core/devtools/osvr_json_to_c.cpp:33:0:
/usr/local/include/json/writer.h:168:70: note: declared here
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
^
devtools/CMakeFiles/osvr_json_to_c.dir/build.make:62: recipe for target 'devtools/CMakeFiles/osvr_json_to_c.dir/osvr_json_to_c.cpp.o' failed
make[2]: *** [devtools/CMakeFiles/osvr_json_to_c.dir/osvr_json_to_c.cpp.o] Error 1
make[2]: Leaving directory '/home/isir/Documents/OSVR-Core/build'
CMakeFiles/Makefile2:1617: recipe for target 'devtools/CMakeFiles/osvr_json_to_c.dir/all' failed
make[1]: *** [devtools/CMakeFiles/osvr_json_to_c.dir/all] Error 2
make[1]: Leaving directory '/home/isir/Documents/OSVR-Core/build'
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
I installed Ubuntu 16.04 on a virtual machine to test this out. I used g++ version 5.4.0 and libjsoncpp-dev version 1.7.2—both from the Ubuntu repositories—and it compiled successfully for me (without the -std=c++11 flag).
Which versions of g++ and jsoncpp are you using?
gcc version 5.4.0 20160609 I'm not sure about the jsoncpp version I'm using, I thought it was a submodule but I can't seem to find it , if it's not I'm using the current master version of the repo.
Fwiw, Travis ci is now doing the same thing. (There is a submodule of vrpn but we don't use it, iirc) https://travis-ci.org/OSVR/OSVR-Core/jobs/469323721
Assuming this is an API break in jsoncpp (or a bug there) - did they go to version 2? Pretty sure 0.y.z and 1.x worked last time I checked.
@rpavlik That's odd. Travis CI is building with jsoncpp version 1.8.4. When I build within my VM, I used that same branch and everything worked okay.
My guess is that the master branch of jsoncpp is using newer C++ features that gcc 5.4.0 doesn't yet support.
@BenoitGeslain Instead of using the master branch of jsoncpp, try checking out and building the 1.8.4 branch and building OSVR against that.