Protobuf build error OpenCV 3.4.2

asked 2018-07-23 06:05:51 -0600

MikeyR gravatar image

Cuda: 9.2 Gcc: 5.4.0 Ubuntu 16.04 Kernel: 4.15.0-24-generic When building OpenCV 3.4.2 with opencv_contrib-3.4.2 I encounter an error which I can't seem to get around.

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D WITH_CUDA=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON ..

Log:

[  4%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/text_format.cc.o
/home/mikeyr/opencv/opencv-3.4.2/3rdparty/protobuf/src/google/protobuf/text_format.cc:1309:1: error: prototype for ‘google::protobuf::TextFormat::Parser::Parser(bool)’ does not match any in class ‘google::protobuf::TextFormat::Parser’
 TextFormat::Parser::Parser(bool allow_unknown_field)
 ^
In file included from /home/mikeyr/opencv/opencv-3.4.2/3rdparty/protobuf/src/google/protobuf/text_format.cc:43:0:
/home/mikeyr/anaconda3/include/google/protobuf/text_format.h:458:28: error: candidates are: google::protobuf::TextFormat::Parser::Parser(const google::protobuf::TextFormat::Parser&)
   class LIBPROTOBUF_EXPORT Parser {
                            ^
/home/mikeyr/anaconda3/include/google/protobuf/text_format.h:460:5: error:                 google::protobuf::TextFormat::Parser::Parser()
     Parser();
     ^
3rdparty/protobuf/CMakeFiles/libprotobuf.dir/build.make:1262: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/text_format.cc.o' failed
make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/text_format.cc.o] Error 1
CMakeFiles/Makefile2:543: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all' failed
make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

When I run with "-D WITH_PROTOBUF=OFF" I run into another error

[ 29%] Building NVCC (Device) object modules/cudawarping/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_warp.cu.o
In file included from /usr/local/cuda/include/cuda_runtime.h:86:0,
                 from <command-line>:0:
/usr/local/cuda/include/builtin_types.h:56:26: fatal error: /usr/local/cuda/include/device_types.h: Operation not permitted
compilation terminated.
CMake Error at cuda_compile_generated_remap.cu.o.cmake:208 (message):
  Error generating
  /home/mikeyr/opencv/opencv-3.4.2/build/modules/cudawarping/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_remap.cu.o


modules/cudawarping/CMakeFiles/opencv_cudawarping.dir/build.make:288: recipe for target 'modules/cudawarping/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_remap.cu.o' failed
make[2]: *** [modules/cudawarping/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_remap.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 29%] Built target opencv_freetype
[ 29%] Built target opencv_fuzzy
[ 29%] Linking CXX shared library ../../lib/libopencv_hfs.so
[ 30%] Built target opencv_cudaarithm
[ 30%] Built target opencv_img_hash
[ 30%] Copy Java(JAR) source files
COPYFILES: ... 1 entries (JAVA_SRC_COPY)
COPYFILES:     ... directory '.../gen/java' with 221 files
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/imgproc/Moments.java' ...
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/imgproc/CLAHE.java' ...
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/imgproc/LineSegmentDetector.java' ...
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/imgproc/Imgproc.java' ...
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/imgproc/Subdiv2D.java' ...
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/highgui/HighGui.java' ...
COPYFILES:         Copying: 'modules/java/jar/opencv/java/org/opencv/highgui/ImageWindow.java ...
(more)
edit retag flag offensive close merge delete

Comments

DId you do a make clean after disabling the -D WITH_PROTOBUF=OFF? Because CUDA should not have a dependency on it.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-23 06:59:04 -0600 )edit

Yeah, and just did it again to test. It crashes with /home/mikeyr/opencv/opencv-3.4.2/modules/cudev/include/opencv2/cudev.hpp:58:37: fatal error: /home/mikeyr/opencv/opencv-3.4.2/modules/cudev/include/opencv2/cudev/util/vec_traits.hpp: Operation not permitted

MikeyR gravatar imageMikeyR ( 2018-07-23 07:18:43 -0600 )edit

Can you first disable CUDA for a second, just to see if that is the problem or something underlying?

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-23 08:00:11 -0600 )edit

It worked WITH_CUDA=OFF, failed compiled one time, but re-ran the make command and then it managed to complete. I kinda need it to be compiled with cuda since I'm using the Zed SDK.

MikeyR gravatar imageMikeyR ( 2018-07-23 08:14:37 -0600 )edit

Are you sure the compute capability is matching your graphics card?

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-23 08:29:48 -0600 )edit

I have a Quadro M1200 with Compute Capability of 5.0, according to wikipedia Cuda 9.X supports compute capability 3.0 – 7.x. So unfortunately that is not the reason. I don't know why I get "operation not permitted errors" when building.

MikeyR gravatar imageMikeyR ( 2018-07-23 08:34:25 -0600 )edit

Can you check your permissions where you are running the make command? From similar google posts it seems your system is somehow blocking access.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-23 08:47:53 -0600 )edit

It was my anti-virus who apparantly killed the process at random places. After stopping it, I can now succesfully compile! Thanks man. Anti-Virus I'm using is BitDefender

MikeyR gravatar imageMikeyR ( 2018-07-23 09:39:55 -0600 )edit

Yeah defenders can block execution rights if they think it is malware. You can solve this by adding exceptions for your executable inside the malware software.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-24 02:10:35 -0600 )edit