构建cmake文件时出现致命错误

时间:2018-02-13 23:08:10

标签: macos opencv cmake python-3.6 macos-sierra

大家好我正在尝试使用opencv的python3.6和我在最后一步使用cmake链接他们make命令我遇到此错误消息我的操作系统是MAC OS Sierra

[85%] Built target example_tutorial_pnp_detection
[85%] Built target example_tutorial_pnp_registration
/Users/mertalptasdelen/opencv/modules/python/src2/cv2.cpp:7:10: fatal error: 'Python.h' file not found
#include <Python.h>
     ^~~~~~~~~~
[ 85%] Built target example_cpp_watershed
[ 86%] Built target example_cpp_videocapture_basic

我的Cmake conf出现了这个错误。是

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m \
-D PYTHON3_EXECUTABLE=/Users/mertalptasdelen/.virtualenvs/cv/bin/python \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_opencv_python3=ON\
-D BUILD_EXAMPLES=ON ..

并且构建完全结果是

[ 85%] Built target example_tutorial_pnp_detection
[ 85%] Built target example_tutorial_pnp_registration
/Users/mertalptasdelen/opencv/modules/python/src2/cv2.cpp:7:10: fatal    error: 'Python.h' file not found
 #include <Python.h>
     ^~~~~~~~~~
 [ 85%] Built target example_cpp_watershed
 [ 86%] Built target example_cpp_videocapture_basic
 [ 86%] Built target example_cpp_videostab
 [ 86%] Built target example_tutorial_video-input-psnr-ssim
 [ 86%] Built target example_cpp_videowriter_basic
 [ 86%] Built target example_tutorial_bg_sub
 [ 86%] Built target example_tutorial_imgproc_HoughLinesPointSet
 [ 86%] Built target example_tutorial_imgcodecs_imwrite
 [ 86%] Built target example_tutorial_core_various
 [ 86%] Built target example_tutorial_cloning_demo
 [ 86%] Built target example_tutorial_npr_demo
 [ 86%] Built target example_tutorial_objectDetection
 [ 86%] Built target example_tutorial_hdr_imaging
 [ 86%] Built target example_tutorial_non_linear_svms
 [ 86%] Built target example_tutorial_introduction_windows_vs
 [ 86%] Built target example_tutorial_display_image
 [ 87%] Built target example_tutorial_pose_from_homography
 [ 87%] Built target example_tutorial_gdal-image.
 [ 87%] Built target example_tutorial_core_merge
 [ 87%] Built target example_tutorial_homography_from_camera_displacement
 [ 87%] Built target example_tutorial_mat_mask_operations
 [ 87%] Built target example_tutorial_perspective_correction
 [ 87%] Built target example_tutorial_how_to_scan_images
 [ 87%] Built target example_tutorial_core_split
 [ 87%] Built target example_tutorial_file_input_output
 [ 87%] Built target example_tutorial_decompose_homography
 [ 87%] Built target example_tutorial_core_mat_checkVector.
 [ 87%] Built target example_tutorial_Drawing_2
 [ 87%] Built target example_tutorial_AddingImages
 [ 87%] Built target example_tutorial_cornerDetector_Demo
 [ 87%] Built target example_tutorial_cornerSubPix_Demo
 Scanning dependencies of target example_tutorial_imageSegmentation
 [ 87%] Built target example_tutorial_pointPolygonTest_demo
 [ 87%] Built target example_tutorial_moments_demo
 Scanning dependencies of target example_tutorial_houghcircles
 Scanning dependencies of target example_tutorial_introduction_to_svm
 [ 87%] Building CXX object  samples/cpp/CMakeFiles/example_tutorial_imageSegmentation.dir/tutorial_co de/ImgTrans/imageSegmentation.cpp.o
 [ 87%] Building CXX object  samples/cpp/CMakeFiles/example_tutorial_houghcircles.dir/tutorial_code/Im gTrans/houghcircles.cpp.o
 [ 87%] Building CXX object  samples/cpp/CMakeFiles/example_tutorial_introduction_to_svm.dir/tutorial_ code/ml/introduction_to_svm/introduction_to_svm.cpp.o
 [ 87%] Linking CXX executable  ../../bin/example_tutorial_houghcircles
 [ 87%] Built target example_tutorial_houghcircles
 Scanning dependencies of target example_tutorial_copyMakeBorder_demo
 [ 87%] Building CXX object  samples/cpp/CMakeFiles/example_tutorial_copyMakeBorder_demo.dir/tutorial_ code/ImgTrans/copyMakeBorder_demo.cpp.o
 [ 87%] Linking CXX executable ../../bin/example_tutorial_introduction_to_svm
 [ 87%] Built target example_tutorial_introduction_to_svm
 Scanning dependencies of target example_tutorial_cornerHarris_Demo
 [ 87%] Building CXX object samples/cpp/CMakeFiles/example_tutorial_cornerHarris_Demo.dir/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp.o
 1 error generated.
 [ 87%] Linking CXX executable ../../bin/example_tutorial_imageSegmentation
 make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
 make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
 make[1]: *** Waiting for unfinished jobs....
 [ 87%] Built target example_tutorial_imageSegmentation
 [ 87%] Linking CXX executable ../../bin/example_tutorial_copyMakeBorder_demo
 [ 87%] Built target example_tutorial_copyMakeBorder_demo
 [ 88%] Linking CXX executable ../../bin/example_tutorial_cornerHarris_Demo
 [ 88%] Built target example_tutorial_cornerHarris_Demo
  make: *** [all] Error 2

任何形式的帮助都是完美的。祝你有愉快的一天。因为我正在努力工作至少2天。我不想放弃。

1 个答案:

答案 0 :(得分:0)

感谢您的回答,但在我添加此行之前它没有帮助我

code export CPLUS_INCLUDE_PATH=/usr/include/python2.7/