Build opencv with opencv_contrib and latest protobuf (3.6.1)

asked 2019-01-31 09:35:28 -0600

swiss_knight gravatar image

updated 2019-02-11 03:56:06 -0600

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.

edit retag flag offensive close merge delete

Comments

1

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"

berak gravatar imageberak ( 2019-02-11 04:44:53 -0600 )edit

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.)

swiss_knight gravatar imageswiss_knight ( 2019-02-11 06:27:22 -0600 )edit
1

in fact, it doesn't work either

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)

berak gravatar imageberak ( 2019-02-11 06:44:50 -0600 )edit

Me too, berak. @swiss_knight. Did you install lib? sudo apt-get -y install libprotobuf-dev protobuf-compiler

supra56 gravatar imagesupra56 ( 2019-02-11 07:35:05 -0600 )edit
1

@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 gravatar imageberak ( 2019-02-11 07:53:25 -0600 )edit

@berak. OOOpppss, sorry. I was using raspberry pi 3b/+, using linux all times.

supra56 gravatar imagesupra56 ( 2019-02-11 08:10:48 -0600 )edit