ubuntu16.04源码编译opencv2.4.9时报错-已经解决

编译环境:Ubuntu16.04,编译工具:cmake3.10.3,同时电脑上安装有python3.6,python2.7。

编译指令如下所示:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv2.4.11 -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D PYTHON_EXECUTABLE=/usr/local/python3-6/bin/python3.6  -D PYTHON_PACKAGES_PATH=/usr/local/python3-6/lib/python3.6/site-packages -D PYTHON_LIBRARY=/usr/local/python3-6/lib/libpython3.6m.so -D PYTHON_INCLUDE_DIR=/usr/local/python3-6/include/python3.6m -D BUILD_EXAMPLES=ON -D BUILD_TIFF=ON -DCUDA_GENERATION=Auto ..

报错信息如下所示:

Determining if the include file io.h exists failed with the following output:
Change Dir: /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_2fa10/fast"
/usr/bin/make -f CMakeFiles/cmTC_2fa10.dir/build.make CMakeFiles/cmTC_2fa10.dir/build
make[1]: Entering directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_2fa10.dir/CheckIncludeFile.c.o
/usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections  -O3 -DNDEBUG   -o CMakeFiles/cmTC_2fa10.dir/CheckIncludeFile.c.o   -c /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:16: fatal error: io.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_2fa10.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_2fa10.dir/CheckIncludeFile.c.o' failed
make[1]: *** [CMakeFiles/cmTC_2fa10.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_2fa10/fast' failed
make: *** [cmTC_2fa10/fast] Error 2


Determining if the function jbg_newlen exists failed with the following output:
Change Dir: /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_26f32/fast"
/usr/bin/make -f CMakeFiles/cmTC_26f32.dir/build.make CMakeFiles/cmTC_26f32.dir/build
make[1]: Entering directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_26f32.dir/CheckFunctionExists.c.o
/usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -DCHECK_FUNCTION_EXISTS=jbg_newlen -O3 -DNDEBUG   -o CMakeFiles/cmTC_26f32.dir/CheckFunctionExists.c.o   -c /usr/local/cmake3.11.1/share/cmake-3.10/Modules/CheckFunctionExists.c
Linking C executable cmTC_26f32
/usr/local/cmake3.11.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_26f32.dir/link.txt --verbose=1
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -DCHECK_FUNCTION_EXISTS=jbg_newlen -O3 -DNDEBUG    -rdynamic CMakeFiles/cmTC_26f32.dir/CheckFunctionExists.c.o  -o cmTC_26f32 
CMakeFiles/cmTC_26f32.dir/CheckFunctionExists.c.o: In function `main':
CheckFunctionExists.c:(.text.startup.main+0xc): undefined reference to `jbg_newlen'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_26f32.dir/build.make:97: recipe for target 'cmTC_26f32' failed
make[1]: *** [cmTC_26f32] Error 1
make[1]: Leaving directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_26f32/fast' failed
make: *** [cmTC_26f32/fast] Error 2


Determining if the include file linux/videodev.h exists failed with the following output:
Change Dir: /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_0a232/fast"
/usr/bin/make -f CMakeFiles/cmTC_0a232.dir/build.make CMakeFiles/cmTC_0a232.dir/build
make[1]: Entering directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0a232.dir/CheckIncludeFile.c.o
/usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections  -O3 -DNDEBUG   -o CMakeFiles/cmTC_0a232.dir/CheckIncludeFile.c.o   -c /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_0a232.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_0a232.dir/CheckIncludeFile.c.o' failed
make[1]: *** [CMakeFiles/cmTC_0a232.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_0a232/fast' failed
make: *** [cmTC_0a232/fast] Error 2


Determining if the include file sys/videoio.h exists failed with the following output:
Change Dir: /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_0db75/fast"
/usr/bin/make -f CMakeFiles/cmTC_0db75.dir/build.make CMakeFiles/cmTC_0db75.dir/build
make[1]: Entering directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0db75.dir/CheckIncludeFile.c.o
/usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections  -O3 -DNDEBUG   -o CMakeFiles/cmTC_0db75.dir/CheckIncludeFile.c.o   -c /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_0db75.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_0db75.dir/CheckIncludeFile.c.o' failed
make[1]: *** [CMakeFiles/cmTC_0db75.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_0db75/fast' failed
make: *** [cmTC_0db75/fast] Error 2


Determining if the include file ffmpeg/avformat.h exists failed with the following output:
Change Dir: /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_7d700/fast"
/usr/bin/make -f CMakeFiles/cmTC_7d700.dir/build.make CMakeFiles/cmTC_7d700.dir/build
make[1]: Entering directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_7d700.dir/CheckIncludeFile.c.o
/usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections  -O3 -DNDEBUG   -o CMakeFiles/cmTC_7d700.dir/CheckIncludeFile.c.o   -c /home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_7d700.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_7d700.dir/CheckIncludeFile.c.o' failed
make[1]: *** [CMakeFiles/cmTC_7d700.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/wq/Downloads/opencv-2.4.9/release/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_7d700/fast' failed
make: *** [cmTC_7d700/fast] Error 2


跪求大神帮忙看看,跪谢

已经解决了,去官网上下载最新的版本没有问题,我下载的是3.4.4 ,按照官网安装即可。猜测是因为我之前下载的太老了

你可能感兴趣的:(opencv)