2014-03-07 1 views
5

나는 2 일 동안 이걸로 지금 고민하고있어 작동하지 않습니다.크로스 컴파일 opencv 프로젝트 우분투 나무 딸기 파이

내가 지금까지했던 어떤 :

  • 내장을 OpenCV 2.4.8을 소스에서 우분투 12.04에 LTS를 -> OpenCV의 프로젝트를 컴파일하고 우분투

  • 내장을 OpenCV에서 실행 2.4.8 소스에서 Raspberry Pi Raspian -> OpenCV 프로젝트가 컴파일되어 라즈베리 파이에서 실행됩니다.

  • 크로스 컴파일러가 내장되어 있습니다. - NG crosstools와 라즈베리 파이에 대한 (http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/) -> C++ 라즈베리 파이


내 문제가 무엇에 크로스 컴파일러 실행 우분투에 내장 된 프로그램 :

  • OpenCV 프로그램은 크로스 컴파일러로 컴파일하지 않습니다.
  • |2|fatal error: opencv2/highgui/highgui.hpp: No such file or directory| 
    

  • 우분투에서 OpenCV를 컴파일해야 할 필요가 있다고 생각합니다. 이 27 %까지 컴파일 make 명령 후

    cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-RaspberryPi.cmake ../ 
    

    : 내 크로스 컴파일러에서 나는 또한 내가이 명령을 OpenCV를 크로스 컴파일하려고이 툴체인을 가진 툴체인

  • # this one is important 
    SET(CMAKE_SYSTEM_NAME Linux) 
    #this one not so much 
    SET(CMAKE_SYSTEM_VERSION 1) 
    
    # specify the cross compiler 
    SET(CMAKE_C_COMPILER 
    /home/christian/Programming/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc) 
    
    SET(CMAKE_CXX_COMPILER 
    /home/christian/Programming/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++) 
    
    # where is the target environment 
    SET(CMAKE_FIND_ROOT_PATH 
    /home/christian/Programming/x-tools/arm-unknown-linux-gnueabi) 
    
    # search for programs in the build host directories 
    SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 
    # for libraries and headers in the target directories 
    SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 
    SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 
    

    있습니다. 거기는 내 우분투 컴퓨터에 라즈베리 파이에 컴파일 OpenCV의 헤더와 libs와 복사하여 연결을 시도

    [ 27%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o 
    In file included from /home/christian/Downloads/opencv-2.4.8/modules/highgui/src/cap_ffmpeg_impl.hpp:60:0, 
           from /home/christian/Downloads/opencv-2.4.8/modules/highgui/src/cap_ffmpeg.cpp:45: 
    /home/christian/Downloads/opencv-2.4.8/modules/highgui/src/ffmpeg_codecs.hpp:81:36: fatal error: libavformat/avformat.h: No such file or directory 
        #include <libavformat/avformat.h> 
                ^
    compilation terminated. 
    make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] Error 1 
    make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 
    make: *** [all] Error 2 
    

  • 이 오류와 함께 중지됩니다.

    가 어떻게 OpenCV의 작동하도록 우분투에 크로스 컴파일러를 얻을 수 있습니다 :

  • ||=== RPi_Cross_CV, Debug ===| 
    ||warning: libz.so.1, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_core.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libjpeg.so.8, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libpng12.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libtiff.so.4, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libjasper.so.1, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgtk-x11-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgdk-x11-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libatk-1.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgio-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libpangoft2-1.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libpangocairo-1.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgdk_pixbuf-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libcairo.so.2, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libpango-1.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libfreetype.so.6, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libfontconfig.so.1, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgobject-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libglib-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgthread-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgstbase-0.10.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgstreamer-0.10.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libgmodule-2.0.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libxml2.so.2, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libdc1394.so.22, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libv4l1.so.0, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libavcodec.so.53, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libavformat.so.53, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libavutil.so.51, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ||warning: libswscale.so.2, needed by ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8, not found (try using -rpath or -rpath-link)| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_3.9'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_time_val_add'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `jas_image_writecmpt'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_widget_queue_draw'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_53'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_51'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_8.0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `jas_cmprof_destroy'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_return_if_fail_warning'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_camera_enumerate'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_capture_stop'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `compress'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_get_image_size_from_video_mode'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_timeout_add'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `v4l2_munmap'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_feature_whitebalance_get_value'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_type_new'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `jas_image_destroy'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_53'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_2'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_core.so.2.4.8||undefined reference to `gzeof'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_style_attach'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_widget_get_type'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_window_resize'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_cond_broadcast'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_video_get_supported_framerates'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_8.0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_53'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_3.9'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `uncompress'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_type_check_instance_cast'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_usleep'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_53'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `g_get_current_time'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_8.0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_video_get_mode'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_8.0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_53'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_window_set_geometry_hints'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_signal_connect_full'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gdk_draw_rgb_image'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_widget_queue_resize'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `dc1394_video_set_mode'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `jas_stream_close'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `[email protected]_8.0'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `jas_image_readcmpt'| 
    ../../../../Programming/x-tools/usr-local/lib/libopencv_highgui.so.2.4.8||undefined reference to `gtk_disable_setlocale'| 
    ||More errors follow but not being shown.| 
    ||Edit the max errors limit in compiler options...| 
    ||=== Build finished: 50 errors, 29 warnings ===| 
    

    를 컴파일하는 동안 나는 그래서 내 질문은 오류의 부하를 얻을? 우분투에서 컴파일하고 Pi에서 프로그램을 복사하여 거기서 실행하고 싶습니다.

    덕분에 당신은이 링크를 다음 라즈베리 파이에 OpenCV의와 Qt는을 (C++) 크로스 컴파일 할 수있는 많은

    답변

    2

    : http://aplacetogeek.wordpress.com/qt-opencv-v4l-cross-compiling-raspberry-pi-beagle-bone/

    것은이 링크는 당신에게 당신의 시스템을 만드는 방법에 대한 모든 필요한 정보를 제공한다 나무 딸기 파이를 위해 교차 할 수 있습니다. 링크가 말하는대로 모든 것을 설정했으면 원하는 경우 Qt없이 C++을 크로스 컴파일 할 때도 opencv 라이브러리를 사용할 수 있다고 생각합니다.

    5

    나는 이것이 오래된 질문이라는 것을 알지만, 기록을 위해 우분투에서 내 OpenCV 프로젝트를 컴파일 할 수있었습니다.

    제 경우에는 github에 미리 만들어진 raspberry pi toolchain을 사용했습니다 : 우분투 12.0.4에서 https://github.com/raspberrypi/tools. 필자는 대상 라즈베리 파이 시스템에서 Ubuntu 인스턴스로 네이티브 라이브러리 (OpenCV 및 PiCamera 라이브러리가 설치된)를 복사하고 게시물에서 언급 한 것처럼 CMAKE_TOOLCHAIN_FILE 지원을 사용하는 방법을 택했습니다. https://solderspot.wordpress.com/2016/02/04/cross-compiling-for-raspberry-pi-part-ii

    중요한 점했다 :

    1. CMAKE_FIND_ROOT_PATH가 영향을 미치지했다

      는 그러나, 나는이 글에서 다루 내가 극복했다 특정 문제가 있었다. CMAKE_SYSROOT을 사용해야했습니다.

    2. 내 CMakeLists.txt 파일에서 네이티브 파일 시스템을 복사 한 폴더 경로의 경로를 명시 적으로 앞에 추가해야했습니다.

    3. 또한 툴 체인이 /usr/etc/ld.so.conf 파일을 올바르게 파싱하지 않으므로 CMAKE_TOOLCHAIN_FILE 내에서 동적 라이브러리 링크 경로를 명시 적으로 지정해야합니다. OpenCV의는 GCC를 사용하기 때문에

    것은 아직 해결되지 수있는 유일한 현재의 문제는, Raspbian의 제시 자료와 함께 할했습니다/g ++ 툴체인의 GCC/G ++ 4.8 버전에서 지원하지 않는 4.9 기능입니다. 가까운 장래에 4.9를 지원하기 위해 툴체인이 보강 될 것으로 보인다.

    내 최종 CMAKE_TOOLCHAIN_FILE했다 : 내 홈 디렉토리에 그 piroot 아래 pidev 폴더를했다

    SET(CMAKE_SYSTEM_NAME Linux) 
    SET(CMAKE_SYSTEM_VERSION 1) 
    
    SET(DEVROOT $ENV{HOME}/pidev) 
    SET(PIROOT ${DEVROOT}/piroot) 
    SET(PITOOLS ${DEVROOT}/pitools) 
    
    SET(TOOLROOT ${PITOOLS}/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64) 
    
    # specify the cross compiler 
    SET(CMAKE_C_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-gcc) 
    SET(CMAKE_CXX_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-g++) 
    
    SET(FLAGS "-Wl,-rpath-link,${PIROOT}/opt/vc/lib -Wl,-rpath-link,${PIROOT}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${PIROOT}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${PIROOT}/usr/local/lib") 
    
    UNSET(CMAKE_C_FLAGS CACHE) 
    UNSET(CMAKE_CXX_FLAGS CACHE) 
    
    SET(CMAKE_CXX_FLAGS ${FLAGS} CACHE STRING "" FORCE) 
    SET(CMAKE_C_FLAGS ${FLAGS} CACHE STRING "" FORCE) 
    
    SET(CMAKE_SYSROOT ${PIROOT}) 
    SET(CMAKE_FIND_ROOT_PATH ${PIROOT}) 
    
    
    # search for programs in the build host directories 
    SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 
    # for libraries and headers in the target directories 
    SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 
    SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 
    

    내 파이로는/usr/옵션은/etc 및/lib 디렉토리의 사본을했다 호스트 및 pitools은 위의 GitHub I toolchain의 복제본입니다. 내 프로젝트에 대한

    내 CMakeLists.txt 파일이었다

    cmake_minimum_required(VERSION 2.8) 
    project(PiCamCVTest) 
    SET(COMPILE_DEFINITIONS -Werror) 
    
    include_directories(SYSTEM ${PIROOT}/opt/vc/include ${PIROOT}/opt/vc/include/interface/vcos/pthreads ${PIROOT}/opt/vc/include/interface/vmcs_host/linux) 
    link_directories(${PIROOT}/opt/vc/lib) 
    add_executable(PiCamCVTest main.cpp camera.cpp cameracontrol.cpp graphics.cpp) 
    
    target_link_libraries(PiCamCVTest libmmal_core.so libmmal_util.so libmmal_vc_client.so libvcos.so librt.so libbcm_host.so GLESv2 EGL libopencv_core.so libopencv_imgproc.so) 
    

    희망이 도움이됩니다.

    +0

    어디에서 pi에서 opencv 라이브러리 복사본을 가져 왔습니까? 내 pi에'sudo apt-get install libopencv-dev'을 실행하고 성공적으로 설치했습니다. 그러나'/ usr/lib','/ lib','/ usr/local/lib'에서 libopencv * .so를 찾을 수 없습니다. 헤더 파일은'/ usr/include/opencv'와'/ usr/include/opencv2'에서만 찾을 수 있습니다. 그러나, 나는 opencv를 사용하여 파이에서 로컬로 컴파일 할 수 있다고 확신하지만 libs가있는 곳을 찾을 수 없습니다. – Alston

    -1

    나는 위의 단계를 따라하고 나는 foolowing 오류가 점점 오전 :

    make[2]: *** No rule to make target '/opt/vc/lib/libmmal_core.so', needed by 'agv_car'. Stop. 
    

    사람을 OpenCV와 raspicam 라이브러리를 사용하는 프로젝트를 크로스 컴파일 관리하고있다?

    +0

    답글이 아닌 댓글 섹션에 의견을 게시하십시오. – Emadpres