c++ - 无法从源代码构建 OpenCV

标签 c++ c opencv cmake makefile

我尝试关注these instructions从源代码构建 OpenCV,但它始终以 17% 左右的速度失败。我创建了一个临时构建目录,运行 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 当出现以下错误时,接着执行make

我尝试在一个干净的构建目录中构建它,以 sudo 运行它,并删除 CMakeCache.txt 文件(有人遇到类似错误,说它有帮助)。

[ 17%] Built target opencv_hal_pch_dephelp
[ 17%] Built target pch_Generate_opencv_hal
[ 17%] Built target opencv_hal
[ 17%] Built target opencv_ts_pch_dephelp
[ 17%] Built target pch_Generate_opencv_ts
[ 17%] Built target opencv_core_pch_dephelp
[ 17%] Built target pch_Generate_opencv_core
[ 17%] Built target opencv_core
[ 17%] Built target opencv_imgproc_pch_dephelp
[ 17%] Built target pch_Generate_opencv_imgproc
[ 17%] Built target opencv_imgproc
[ 17%] Built target opencv_imgcodecs_pch_dephelp
[ 17%] Built target pch_Generate_opencv_imgcodecs
[ 17%] Built target opencv_imgcodecs
[ 17%] Built target opencv_videoio_pch_dephelp
[ 17%] Built target pch_Generate_opencv_videoio
[ 17%] Linking CXX shared library ../../lib/libopencv_videoio.so
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:285: recipe for target 'lib/libopencv_videoio.so.3.0.0' failed
CMakeFiles/Makefile2:4401: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
Makefile:160: recipe for target 'all' failed

最佳答案

这是gcc-6.1的一个bug,请将你的gcc降级到gcc-5.3。

sudo apt-get install gcc-5.3 g++-5.3
rm /usr/bin/gcc
ln -s /usr/bin/gcc-5 /usr/bin/gcc
rm /usr/bin/g++
ln -s /usr/bin/g++-5 /usr/bin/g++

现在,您可以再次使用 cmake 了。

关于c++ - 无法从源代码构建 OpenCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33381433/

相关文章:

python - 整数参数预期int在opencv中 float

C++ 将 enum 和 string 组合成一个类似 map 的变量,可以与 int 和 string 一起使用

C++17模板参数推导之谜

c++ - Ubuntu C++ UDP 包没有到达

c - 使用回调和嵌套列表的 C 前缀表达式计算器

python - 使用 cv2 填充字符中的空白

c++ - Q_PROPERTY WRITE 获取索引

c - Unix top 命令列从另一个 C 程序中选择?

c - 读写就地不写?

opencv - 在opencv中将Mat转换为iplimage *