2016-11-15 6 views
0

Я следовал этим инструкциям, чтобы загрузить OpenCV 3.1.0:Ошибки с загрузкой OpenCV в Ubuntu

http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/

Однако, после того, как не выполнив команду make -j4 процессы кода до 14%, то результат выглядит следующим образом , давая ошибку в том, что существует фатальная ошибка math.h ...

[ 0%] Built target opencv_hal_pch_dephelp 
[ 0%] Built target opencv_core_pch_dephelp 
[ 0%] Built target opencv_test_core_pch_dephelp 
[ 0%] Built target opencv_perf_core_pch_dephelp 
[ 0%] Built target opencv_imgproc_pch_dephelp 
[ 0%] Built target opencv_highgui_pch_dephelp 
[ 0%] Built target opencv_videoio_pch_dephelp 
[ 0%] Built target pch_Generate_opencv_test_core 
[ 0%] Built target opencv_imgcodecs_pch_dephelp 
[ 0%] Built target opencv_ts_pch_dephelp 
[ 0%] Built target pch_Generate_opencv_perf_core 
[ 0%] Built target opencv_test_flann_pch_dephelp 
[ 0%] Built target opencv_flann_pch_dephelp 
[ 0%] Built target opencv_test_imgproc_pch_dephelp 
[ 0%] Built target opencv_ml_pch_dephelp 
[ 0%] Built target opencv_perf_imgproc_pch_dephelp 
[ 0%] Built target opencv_photo_pch_dephelp 
[ 0%] Built target opencv_test_ml_pch_dephelp 
[ 0%] Built target opencv_test_photo_pch_dephelp 
[ 0%] Built target opencv_perf_photo_pch_dephelp 
[ 1%] Built target opencv_reg_pch_dephelp 
[ 1%] Built target opencv_perf_reg_pch_dephelp 
[ 1%] Built target opencv_test_reg_pch_dephelp 
[ 1%] Built target opencv_surface_matching_pch_dephelp 
[ 1%] Built target opencv_video_pch_dephelp 
[ 1%] Built target opencv_perf_video_pch_dephelp 
[ 2%] Built target opencv_test_viz_pch_dephelp 
[ 2%] Built target opencv_test_video_pch_dephelp 
[ 2%] Built target opencv_face_pch_dephelp 
[ 2%] Built target opencv_viz_pch_dephelp 
[ 2%] Built target opencv_perf_imgcodecs_pch_dephelp 
[ 2%] Built target opencv_test_imgcodecs_pch_dephelp 
[ 2%] Built target opencv_shape_pch_dephelp 
[ 2%] Built target opencv_test_shape_pch_dephelp 
[ 2%] Built target opencv_test_videoio_pch_dephelp 
[ 2%] Built target opencv_test_highgui_pch_dephelp 
[ 2%] Built target opencv_perf_videoio_pch_dephelp 
[ 3%] Built target opencv_objdetect_pch_dephelp 
[ 4%] Built target opencv_perf_objdetect_pch_dephelp 
[ 4%] Built target opencv_optflow_pch_dephelp 
[ 4%] Built target opencv_test_objdetect_pch_dephelp 
[ 4%] Built target opencv_superres_pch_dephelp 
[ 6%] Built target opencv_test_optflow_pch_dephelp 
[ 6%] Built target opencv_test_superres_pch_dephelp 
[ 6%] Built target opencv_tracking_pch_dephelp 
[ 6%] Built target opencv_perf_superres_pch_dephelp 
[ 6%] Built target opencv_test_tracking_pch_dephelp 
[ 6%] Built target opencv_perf_tracking_pch_dephelp 
[ 6%] Built target opencv_ximgproc_pch_dephelp 
[ 7%] Built target opencv_test_ximgproc_pch_dephelp 
[ 7%] Built target opencv_perf_ximgproc_pch_dephelp 
[ 7%] Built target opencv_xobjdetect_pch_dephelp 
[ 7%] Built target opencv_test_xphoto_pch_dephelp 
[ 7%] Built target opencv_bgsegm_pch_dephelp 
[ 7%] Built target opencv_bioinspired_pch_dephelp 
[ 7%] Built target opencv_test_bgsegm_pch_dephelp 
[ 8%] Built target opencv_test_bioinspired_pch_dephelp 
[ 9%] Built target opencv_perf_bioinspired_pch_dephelp 
[ 9%] Built target opencv_perf_features2d_pch_dephelp 
[ 10%] Built target opencv_features2d_pch_dephelp 
[ 10%] Built target opencv_test_features2d_pch_dephelp 
Scanning dependencies of target pch_Generate_opencv_perf_features2d 
[ 10%] Built target opencv_latentsvm_pch_dephelp 
[ 10%] Generating perf_precomp.hpp 
[ 10%] Generating perf_precomp.hpp.gch/opencv_perf_features2d_RELEASE.gch 
[ 10%] Built target opencv_perf_latentsvm_pch_dephelp 
[ 10%] Built target opencv_test_latentsvm_pch_dephelp 
[ 10%] Built target opencv_test_line_descriptor_pch_dephelp 
[ 10%] Built target opencv_line_descriptor_pch_dephelp 
Scanning dependencies of target pch_Generate_opencv_test_line_descriptor 
[ 10%] Generating test_precomp.hpp 
[ 10%] Generating test_precomp.hpp.gch/opencv_test_line_descriptor_RELEASE.gch 
[ 10%] Built target pch_Generate_opencv_perf_features2d 
[ 10%] Built target opencv_perf_line_descriptor_pch_dephelp 
[ 10%] Built target opencv_saliency_pch_dephelp 
[ 10%] Built target opencv_text_pch_dephelp 
[ 10%] Built target opencv_test_calib3d_pch_dephelp 
[ 10%] Built target opencv_calib3d_pch_dephelp 
[ 10%] Built target opencv_perf_calib3d_pch_dephelp 
[ 10%] Built target opencv_ccalib_pch_dephelp 
[ 10%] Built target opencv_rgbd_pch_dephelp 
[ 10%] Built target opencv_test_rgbd_pch_dephelp 
[ 10%] Built target opencv_videostab_pch_dephelp 
[ 12%] Built target opencv_xfeatures2d_pch_dephelp 
[ 12%] Built target pch_Generate_opencv_test_line_descriptor 
[ 12%] Built target opencv_test_xfeatures2d_pch_dephelp 
[ 12%] Built target opencv_perf_xfeatures2d_pch_dephelp 
[ 12%] Built target opencv_test_stitching_pch_dephelp 
[ 13%] Built target opencv_perf_stitching_pch_dephelp 
[ 14%] Built target opencv_stitching_pch_dephelp 
[ 14%] Built target pch_Generate_opencv_hal 
[ 14%] Generating precomp.hpp.gch/opencv_core_RELEASE.gch 
In file included from /home/sciencefair/opencv/modules/hal/include/opencv2/hal/defs.h:329:0, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core/cvdef.h:59, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core.hpp:52, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core/utility.hpp:52, 
       from /home/sciencefair/opencv/build/modules/core/precomp.hpp:49: 
/usr/include/c++/6/cmath:45:23: fatal error: math.h: No such file or directory 
#include_next <math.h> 
        ^
compilation terminated. 
modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:62: recipe for target 'modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch' failed 
make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch] Error 1 
CMakeFiles/Makefile2:1875: recipe for target 'modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all' failed 
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2 
make[1]: *** Waiting for unfinished jobs.... 
[ 14%] Built target pch_Generate_opencv_highgui 
Makefile:149: recipe for target 'all' failed 
make: *** [all] Error 2 
[email protected] 

Любые идеи? Заранее спасибо.

UPDATE: Я добавил math.h в PATH, и эта ошибка исчезла. Однако теперь я получаю сообщение об ошибке с помощью stdlib.h. Результат выглядит следующим образом.

[ 0%] Built target opencv_core_pch_dephelp 
[ 0%] Built target opencv_imgproc_pch_dephelp 
[ 0%] Built target opencv_perf_core_pch_dephelp 
[ 0%] Built target opencv_imgcodecs_pch_dephelp 
[ 0%] Built target opencv_test_core_pch_dephelp 
[ 0%] Built target opencv_videoio_pch_dephelp 
[ 0%] Built target opencv_ts_pch_dephelp 
[ 1%] Built target opencv_highgui_pch_dephelp 
[ 1%] Built target pch_Generate_opencv_perf_core 
[ 1%] Built target opencv_test_flann_pch_dephelp 
[ 1%] Built target opencv_flann_pch_dephelp 
[ 1%] Built target opencv_hdf_pch_dephelp 
[ 1%] Built target opencv_test_imgproc_pch_dephelp 
[ 1%] Built target opencv_test_ml_pch_dephelp 
[ 1%] Built target opencv_perf_imgproc_pch_dephelp 
[ 1%] Built target opencv_ml_pch_dephelp 
[ 1%] Built target opencv_perf_photo_pch_dephelp 
[ 1%] Built target opencv_photo_pch_dephelp 
[ 1%] Built target opencv_test_photo_pch_dephelp 
[ 1%] Built target opencv_reg_pch_dephelp 
[ 2%] Built target opencv_test_reg_pch_dephelp 
[ 2%] Built target opencv_perf_reg_pch_dephelp 
[ 2%] Built target opencv_surface_matching_pch_dephelp 
[ 2%] Built target opencv_video_pch_dephelp 
[ 2%] Built target opencv_test_video_pch_dephelp 
[ 2%] Built target opencv_perf_video_pch_dephelp 
[ 2%] Built target opencv_test_viz_pch_dephelp 
[ 2%] Built target opencv_viz_pch_dephelp 
[ 2%] Built target opencv_dnn_pch_dephelp 
[ 2%] Built target opencv_test_dnn_pch_dephelp 
[ 3%] Built target libprotobuf 
[ 3%] Built target opencv_fuzzy_pch_dephelp 
[ 3%] Built target opencv_test_imgcodecs_pch_dephelp 
[ 3%] Built target opencv_test_fuzzy_pch_dephelp 
[ 3%] Built target opencv_perf_imgcodecs_pch_dephelp 
[ 3%] Built target opencv_test_shape_pch_dephelp 
[ 3%] Built target opencv_shape_pch_dephelp 
[ 3%] Built target opencv_test_videoio_pch_dephelp 
[ 3%] Built target opencv_perf_objdetect_pch_dephelp 
[ 3%] Built target opencv_test_objdetect_pch_dephelp 
[ 3%] Built target opencv_test_highgui_pch_dephelp 
[ 3%] Built target opencv_perf_videoio_pch_dephelp 
[ 3%] Built target opencv_objdetect_pch_dephelp 
[ 3%] Built target opencv_test_superres_pch_dephelp 
[ 3%] Built target opencv_superres_pch_dephelp 
[ 5%] Built target opencv_plot_pch_dephelp 
[ 5%] Built target opencv_perf_superres_pch_dephelp 
[ 5%] Built target opencv_xobjdetect_pch_dephelp 
[ 5%] Built target opencv_test_xphoto_pch_dephelp 
[ 5%] Built target opencv_perf_xphoto_pch_dephelp 
[ 5%] Built target opencv_bgsegm_pch_dephelp 
[ 5%] Built target opencv_test_bioinspired_pch_dephelp 
[ 5%] Built target opencv_bioinspired_pch_dephelp 
[ 5%] Built target opencv_test_bgsegm_pch_dephelp 
[ 6%] Built target opencv_perf_bioinspired_pch_dephelp 
[ 6%] Built target opencv_dpm_pch_dephelp 
[ 7%] Built target opencv_face_pch_dephelp 
[ 8%] Built target opencv_features2d_pch_dephelp 
[ 10%] Built target opencv_perf_features2d_pch_dephelp 
[ 10%] Built target opencv_test_features2d_pch_dephelp 
[ 10%] Built target opencv_test_line_descriptor_pch_dephelp 
[ 10%] Built target opencv_line_descriptor_pch_dephelp 
[ 10%] Built target opencv_perf_line_descriptor_pch_dephelp 
[ 10%] Built target opencv_calib3d_pch_dephelp 
[ 11%] Built target opencv_saliency_pch_dephelp 
[ 12%] Built target opencv_text_pch_dephelp 
[ 12%] Built target opencv_ccalib_pch_dephelp 
[ 12%] Built target opencv_test_calib3d_pch_dephelp 
[ 12%] Built target opencv_perf_calib3d_pch_dephelp 
[ 13%] Built target opencv_rgbd_pch_dephelp 
[ 13%] Built target opencv_test_rgbd_pch_dephelp 
[ 15%] Built target opencv_perf_stereo_pch_dephelp 
[ 16%] Built target opencv_stereo_pch_dephelp 
[ 16%] Built target opencv_structured_light_pch_dephelp 
[ 16%] Built target opencv_test_stereo_pch_dephelp 
[ 16%] Built target opencv_test_structured_light_pch_dephelp 
[ 16%] Built target opencv_tracking_pch_dephelp 
[ 16%] Built target opencv_perf_tracking_pch_dephelp 
[ 16%] Built target opencv_test_tracking_pch_dephelp 
[ 16%] Built target opencv_videostab_pch_dephelp 
[ 16%] Built target opencv_perf_xfeatures2d_pch_dephelp 
[ 16%] Built target opencv_perf_ximgproc_pch_dephelp 
[ 16%] Built target opencv_xfeatures2d_pch_dephelp 
[ 16%] Built target opencv_test_ximgproc_pch_dephelp 
[ 16%] Built target opencv_test_xfeatures2d_pch_dephelp 
[ 16%] Built target opencv_ximgproc_pch_dephelp 
[ 16%] Built target opencv_test_aruco_pch_dephelp 
[ 17%] Built target opencv_aruco_pch_dephelp 
[ 17%] Built target opencv_optflow_pch_dephelp 
[ 17%] Built target opencv_test_optflow_pch_dephelp 
[ 17%] Built target opencv_stitching_pch_dephelp 
[ 17%] Built target opencv_test_stitching_pch_dephelp 
[ 17%] Built target opencv_perf_stitching_pch_dephelp 
[ 17%] Generating precomp.hpp.gch/opencv_core_RELEASE.gch 
Scanning dependencies of target pch_Generate_opencv_imgproc 
Scanning dependencies of target pch_Generate_opencv_imgcodecs 
[ 17%] Generating precomp.hpp 
[ 17%] Built target pch_Generate_opencv_test_core 
[ 17%] Generating precomp.hpp 
Scanning dependencies of target pch_Generate_opencv_videoio 
[ 17%] Generating precomp.hpp.gch/opencv_imgcodecs_RELEASE.gch 
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0, 
       from /usr/include/c++/6/algorithm:62, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core/base.hpp:53, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core.hpp:54, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core/utility.hpp:52, 
       from /home/sciencefair/opencv/build/modules/core/precomp.hpp:49: 
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory 
#include_next <stdlib.h> 
         ^
compilation terminated. 
[ 17%] Generating precomp.hpp.gch/opencv_imgproc_RELEASE.gch 
modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:62: recipe for target 'modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch' failed 
make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch] Error 1 
CMakeFiles/Makefile2:1887: recipe for target 'modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all' failed 
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2 
make[1]: *** Waiting for unfinished jobs.... 
[ 17%] Generating precomp.hpp 
[ 17%] Generating precomp.hpp.gch/opencv_videoio_RELEASE.gch 
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0, 
       from /usr/include/c++/6/algorithm:62, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core/base.hpp:53, 
       from /home/sciencefair/opencv/modules/core/include/opencv2/core.hpp:54, 
       from /home/sciencefair/opencv/modules/imgcodecs/include/opencv2/imgcodecs.hpp:46, 
       from /home/sciencefair/opencv/build/modules/imgcodecs/precomp.hpp:45: 
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory 
#include_next <stdlib.h> 
         ^
compilation terminated. 
modules/imgcodecs/CMakeFiles/pch_Generate_opencv_imgcodecs.dir/build.make:62: recipe for target 'modules/imgcodecs/precomp.hpp.gch/opencv_imgcodecs_RELEASE.gch' failed 
make[2]: *** [modules/imgcodecs/precomp.hpp.gch/opencv_imgcodecs_RELEASE.gch] Error 1 
CMakeFiles/Makefile2:5875: recipe for target 'modules/imgcodecs/CMakeFiles/pch_Generate_opencv_imgcodecs.dir/all' failed 
make[1]: *** [modules/imgcodecs/CMakeFiles/pch_Generate_opencv_imgcodecs.dir/all] Error 2 
[ 17%] Built target pch_Generate_opencv_imgproc 
[ 17%] Built target pch_Generate_opencv_videoio 
Makefile:160: recipe for target 'all' failed 
make: *** [al 

л] Ошибка 2

Любые идеи? Благодаря!

ДРУГОЕ ОБНОВЛЕНИЕ: Я выполнил следующие инструкции: http://rodrigoberriel.com/2014/10/installing-opencv-3-0-0-on-ubuntu-14-04/ , в котором им требуется запустить файл sh, который они предоставляют. Однако ошибки продолжают сохраняться с помощью stdlib.h. Я неоднократно проверял, что stdlib.h является переменной окружения и что stdlib.h существует в usr/include. Файл ш выглядит следующим образом ...

#!/bin/bash 

########################################################### 
# 
# OpenCV 3.0.0 alpha - instalação 
# http://opencv.org/ 
# 
########################################################### 

#---------------------------------------------------------- 
# Criando um logger para registrar a instalação 
#---------------------------------------------------------- 
# Tempo: início 
dateformat="+%a %b %-eth %Y %I:%M:%S %p %Z" 
starttime=$(date "$dateformat") 
starttimesec=$(date +%s) 

# Pega o diretório atual 
curdir=$(cd `dirname $0` && pwd) 

# Cria o arquivo onde as ações ficarão registradas 
logfile="$curdir/install-opencv.log" 
rm -f $logfile 

# Logger simples 
log(){ 
    timestamp=$(date +"%Y-%m-%d %k:%M:%S") 
    echo "\n$timestamp $1" 
    echo "$timestamp $1" >> $logfile 2>&1 
} 

# Iniciando a instalação do OpenCV 3.0.0 
log "Iniciando a instalação do OpenCV 3.0.0" 


#---------------------------------------------------------- 
# Assegurando um ambiente atualizado 
#---------------------------------------------------------- 

# Informa ao usuário a próxima ação 
log "Executando apt-get update e apt-get upgrade" 

# Executa a ação 
sudo apt-get update 
sudo apt-get upgrade 


#---------------------------------------------------------- 
# Instalando os pacotes das dependências 
#---------------------------------------------------------- 

log "Instalando as dependências" 

# Executa a ação 
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip 


#---------------------------------------------------------- 
# Instalando OpenCV 
#---------------------------------------------------------- 

log "Baixando a biblioteca OpenCV 3.0.0" 

# Definição de constante 
FOLDER_NAME="opencv" 

# Cria um novo diretório para armazenar o código-fonte 
mkdir ${FOLDER_NAME} 

# Entra no diretório 
cd ${FOLDER_NAME} 

# Baixa o código-fonte 
wget https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip -O opencv-3.0.0-alpha.zip 

# Extrai o conteúdo 
unzip opencv-3.0.0-alpha.zip 

log "Instalando a biblioteca OpenCV 3.0.0" 

# Entra no diretório 
cd opencv-3.0.0-alpha 

# Cria um diretório chamado 'build' 
mkdir build 

# Entra no diretório 
cd build 

# Constrói o projeto usando CMake 
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON .. 

# Compila o projeto 
make -j $(nproc) 

# Instala as bibliotecas na pasta apropriada 
sudo make install 

# Adiciona o caminho das bibliotecas do OpenCV aos caminhos de pesquisa de biblioteca padrão do Ubuntu 
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' 

# Atualiza os caminhos de pesquisa de biblioteca padrão do Ubuntu 
sudo ldconfig 

# Informa ao usuário que o OpenCV foi instalado com sucesso! 
log "OpenCV 3.0.0 foi instalado com sucesso!" 

#---------------------------------------------------------- 
# Mostra tempo gasto com a instalação 
#---------------------------------------------------------- 

# Tempo: fim 
endtime=$(date "$dateformat") 
endtimesec=$(date +%s) 

# Mostra tempo gasto com a instalação 
elapsedtimesec=$(expr $endtimesec - $starttimesec) 
ds=$((elapsedtimesec % 60)) 
dm=$(((elapsedtimesec/60) % 60)) 
dh=$((elapsedtimesec/3600)) 
displaytime=$(printf "%02d:%02d:%02d" $dh $dm $ds) 
log "Tempo gasto: $displaytime\n" 

ответ

0

Ну, это было долгое решение ... Кажется, что добавление переменной в PATH не было проблемой. Проблема была в G ++ и GCC версии 6. Поэтому после перенаправления gcc и g ++ на gcc и g ++ версии 5 все получилось.

0

Проблема с отсутствующими math.h файлом. make Цель цели cmath файл который включает math.h (строка 45 в cmath) файл. Как правило, вы найдете math.h в /usr/include/math.h.

Если его там, то для его работы вы можете добавить /usr/include в $PATH переменной окружения. Вы можете искать онлайн, чтобы добавить каталог в $PATH, или вы также можете проверить here.

Если его нет, вам необходимо найти файл в системе и указать его путь к цели make.

+0

@ rehaan-ahmad Если это не работает, мне понадобятся дополнительные журналы ошибок – radbrawler

+0

Я добавил это к своему пути, и теперь ошибка math.h исчезла. Но теперь я получаю ошибку stdlib.h. Я добавил stdlib на свой путь, однако ошибка сохраняется, теперь я обновил этот вопрос. –

+0

Какой путь вы включили для stdlib ./ @ rehaan-ahmad – radbrawler