Ubuntu20.04安装OpenCV3.20报错及解决

  1. /usr/include/c++/9/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录 解决:cmake时加上参数-D ENABLE_PRECOMPILED_HEADERS=OFF

  2. error: 'CODEC_FLAG_GLOBAL_HEADER' was not declared in this scope 解决:opencv/opencv-3.2.0/modules/videoio/src/cap_ffmpeg_impl.hpp 里最顶端添加了3

    #define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
    #define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
    #define AVFMT_RAWPICTURE 0x0020`
  3. make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/build.make:56: modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1make[1]: *** [CMakeFiles/Makefile2:21149: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
    解决:找cv2.cpp,将
    char* str = PyString_AsString(obj);
    改为
    char* str = (char *)PyString_AsString(obj);

Ubuntu20.04安装OpenCV3.20报错及解决_第1张图片

 

你可能感兴趣的:(opencv,c++,ubuntu)