Build opencv with opencv_contrib and latest protobuf (3.6.1)
Hi.
I'm trying to build opencv from sources (https://github.com/opencv/opencv > master) with opencv_contrib which I locally cloned. I've prior installed protobuf 3.6.1 (https://github.com/protocolbuffers/pr...) and caffe (https://github.com/BVLC/caffe) the same way.
But I've got many thousands (!!) of errors like:
/opt/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.cc:33983:30: error: ‘GOOGLE_PREDICT_TRUE’ was not declared in this scope
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
or
In file included from /opt/opencv/modules/dnn/src/caffe/caffe_io.hpp:98:0,
from /opt/opencv/modules/dnn/src/caffe/caffe_importer.cpp:52:
/opt/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^~~~~
/opt/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^~~~~
/opt/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.
^~~~~
ending in:
modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:91: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/misc/caffe/opencv-caffe.pb.cc.o' failed
make[2]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/misc/caffe/opencv-caffe.pb.cc.o] Error 1
CMakeFiles/Makefile2:3756: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/all' failed
make[1]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
So, I wonder how to install opencv (from master branch) with the latest version of protobuf (3.6.1) ?
Note that I set the Build_Protobuf option to Off during configuration with cmake and make the protobuf libraries pointing directly to the freshly installed ones in /usr/local/.
I also compiled caffe using protobuf 3.6.1 and everything went fine there.
Thanks.
is there any special reason you need this protobuf version ?
if you build with
cmake -DBUILD_PROTOBUF=ON
it will pickup the 3rdparty version from the opencv src, which might be a bit back, but is at least "known to work"in fact, it doesn't work either. Had same issues with caffe and dnn. (caffe was compiled using protobuf 3.6.1 on my machine. So, it's probably related.)
hmm it works for me, the buildbots and anyone else i know. try again, and give a more detailled report ("doesn't work" is never a helpful description)
Me too, berak. @swiss_knight. Did you install lib?
sudo apt-get -y install libprotobuf-dev protobuf-compiler
@supra56 -- why sow more confusion here, than nessecary ?
again, the canonical solution (to build the dnn module) is to use openv's (precompiled) 3rdparty protobuf, not any thing from apt-get, seriously why that ?
@berak. OOOpppss, sorry. I was using raspberry pi 3b/+, using linux all times.