(죄송합니다, 불량 영어, 저는 독일어입니다) 안녕하세요 프로그래머, 필자는 필자의 리눅스 (fedora) x86_x64 노트북에서 OpenCV를 사용하여 프로그램을 컴파일하려고 필사적으로 노력하고 있습니다. 리눅스 (raspian) 라즈베리 파이 3.라즈베리 파이 opencv 링크 문제에 대한 크로스 컴파일
위해 나는 < < "테스트 \ n을"COUT이 튜토리얼 (https://solderspot.wordpress.com/2016/02/04/cross-compiling-for-raspberry-pi-part-ii/) 간단한 표준을 :: 다음 해요; 프로그램을 컴파일하고 다음 CMakeLists.txt와 함께 잘 작동 : 그것은 (분명한 이유) 많은 "정의되지 않은 참조"오류가 발생 위에서 나는 CMakeLists.txt를 사용하는 경우
cmake_minimum_required (VERSION 2.8)
project (CVS)
find_package(OpenCV REQUIRED)
SET(COMPILE_DEFINITIONS -Werror)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DHOST_ROBO_DIR=/home/username/Dropbox/Roboter)
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 (CVS ../source/main.cpp)
문제가 OpenCV의 ... 와 함께 제공 예 : "cv :: waitKey (int)"에 대한 정의되지 않은 참조 "
CMakeLists.txt에"target_link_libraries (CVS $ {OpenCV_LIBS}) "또는"target_link_libraries (CVS -lopencv_core) 다음 오류 : /home/username/pidev/piroot/usr/local/lib/libopencv_core.so : 'std :: __ throw_out_of_range_fmt (char const *, ...)에 대한 정의되지 않은 참조 @ GLIBCXX_3.4.20'
~/pidev/pi-toolchain.cmake에서 "SET (TOOLROOT $ {PITOOLS}/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64) 사람이 이러한 질문 중 하나를 대답 할 수 있다면
[[email protected] msi]$ cmake -DCMAKE_TOOLCHAIN_FILE=~/pidev/pi-toolchain.cmake .
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"/home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/username/Dropbox/Roboter/raspySync/CVS/cvs5-6/msi/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_b1abe/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_b1abe.dir/build.make
CMakeFiles/cmTC_b1abe.dir/build
gmake[1]: Verzeichnis
„/home/username/Dropbox/Roboter/raspySync/CVS/cvs5-6/msi/CMakeFiles/CMakeTmp“
wird betreten
Building C object CMakeFiles/cmTC_b1abe.dir/testCCompiler.c.o
/home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
--sysroot=/home/username/pidev/piroot
-Wl,-rpath-link,/home/username/pidev/piroot/opt/vc/lib
-Wl,-rpath-link,/home/username/pidev/piroot/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/home/username/pidev/piroot/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/home/username/pidev/piroot/usr/local/lib -o
CMakeFiles/cmTC_b1abe.dir/testCCompiler.c.o -c
/home/username/Dropbox/Roboter/raspySync/CVS/cvs5-6/msi/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_b1abe
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b1abe.dir/link.txt
--verbose=1
/home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
--sysroot=/home/username/pidev/piroot
-Wl,-rpath-link,/home/username/pidev/piroot/opt/vc/lib
-Wl,-rpath-link,/home/username/pidev/piroot/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/home/username/pidev/piroot/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/home/username/pidev/piroot/usr/local/lib
CMakeFiles/cmTC_b1abe.dir/testCCompiler.c.o -o cmTC_b1abe -rdynamic
/home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld:
cannot find crt1.o: No such file or directory
/home/username/pidev/pitools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld:
cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_b1abe.dir/build.make:97: die Regel für Ziel
„cmTC_b1abe“ scheiterte
gmake[1]: *** [cmTC_b1abe] Fehler 1
gmake[1]: Verzeichnis
„/home/username/Dropbox/Roboter/raspySync/CVS/cvs5-6/msi/CMakeFiles/CMakeTmp“
wird verlassen
Makefile:126: die Regel für Ziel „cmTC_b1abe/fast“ scheiterte
gmake: *** [cmTC_b1abe/fast] Fehler 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/home/username/Dropbox/Roboter/raspySync/CVS/cvs5-6/msi/CMakeFiles/CMakeOutput.log".
See also "/home/username/Dropbox/Roboter/raspySync/CVS/cvs5-6/msi/CMakeFiles/CMakeError.log".
[[email protected] msi]$
내가 감사 할 것 : {PITOOLS} /arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf)는 "나는 다음과 같은 오류 가지고 을 - 어떻게 OpenCV 명령을 사용하는 프로그램을 크로스 컴파일 할 수 있습니까? - "std :: __ throw_out_of_range_fmt (char const *, ...) @ GLIBCXX_3.4.20 '"및 "The C compiler ..."에 대한 정의되지 않은 참조가있는 이유는 무엇입니까? 간단한 테스트 프로그램을 컴파일 할 수 없습니다. " - 내가 프로그램에서이 같은 뭔가를 추가하면 나쁜 또는 정말 나쁜 스타일 같습니다
namespace std
{
void __throw_out_of_range_fmt(char const*, ...)
{
std::cout << "throw out of range error\n";
}
}
Heres는 내 ~/pidev/파이 - toolchain.cmake :
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(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)
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)