2012-07-19 1 views
0

ARM Cortex A8 기반 AM3359 프로세서가있는 비글 본에 대한 샘플 OpenCV cpp 코드를 크로스 컴파일하려고합니다. 내가 시작할 때 크로스 컴파일 나는 다음과 같은 오류 얻을 : 잘못된 형식 collect2에 파일 :샘플 cpp (libopencv_calib3d.so : 심볼을 읽을 수 없음)를 크로스 컴파일하는 동안 Opencv 링커 오류가 발생했습니다.

/usr/local/lib/libopencv_calib3d.so : 읽을 수없는 문자 신분증 1 종료 상태

을 반환 링커 오류 인 것 같습니다. libopencv_calib3d.so에는 아무 문제가 없다고 확신합니다. 내 PC 용 프로그램을 컴파일하면 모든 것이 잘 작동하기 때문입니다. 그러므로 문제는 내가 크로스 컴파일을 위해 사용하고있는 방법에있다.

내가 compile_opencvarm.sh의 이름으로 스크립트를 작성 :

echo "Cross-Compiling $1" 
if [[ $1 == *.c ]] 
then 
    arm-linux-gnueabi-gcc -ggdb `pkg-config --cflags opencv` -o `basename $1 .c` $1 `pkg-config --libs opencv`; 
elif [[ $1 == *.cpp ]] 
then 
    arm-linux-gnueabi-g++ -ggdb `pkg-config --cflags opencv` -o `basename $1 .cpp` $1  `pkg-config --libs opencv`; 
else 
    echo "Please compile only .c or .cpp files with this script" 
fi 
echo "Cross-Compiled Output => ${1%.*}" 

다음 bashrc에이를 추가 :

alias opencv_arm="~/.compile_opencvarm.sh" 

을 이제 내가 할 때 여기에 내가 무엇을

[email protected]:/home/zero/Desktop# opencv_arm peopledetect.cpp 
Cross-Compiling peopledetect.cpp 
/usr/local/lib/libopencv_calib3d.so: could not read symbols: File in wrong format 
collect2: ld returned 1 exit status 
Cross-Compiled Output => peopledetect 

컴파일 스크립트와 크로스 컴파일 스크립트의 차이점은 십자형에서 arm-linux-gnueabi 접두사를 사용한다는 것입니다 ompiling 스크립트. cpp 파일 만 컴파일 할 때 :

[email protected]:/home/zero/Desktop# opencv peopledetect.cpp 
compiling peopledetect.cpp 
Output file => peopledetect 

모두 괜찮습니다. 프로그램은 실행 가능합니다.

내 문제는 무엇이라고 생각하십니까? 그것은 링커 오류입니까 아니면 내 상호 편집 프로세스와 관련이 있습니까?

감사

편집 : 아, 이제 내가 팔 - 리눅스 - gnueabi 컴파일러를 사용하기 전에 ARM 기반 크로스 라이브러리를 설치하지 않은 것으로 나타났습니다. 그래서 나는 그들을 설치 :

sudo xapt -a armel -m libv4l-dev libgtk2.0-dev libcv-dev libcvaux-dev libhighgui-dev 

하고 다음과 같은 스크립트를 편집 :

arm-linux-gnueabi-g++ -ggdb `arm-linux-gnueabi-pkg-config --cflags opencv` -o `basename $1 .cpp` $1 `arm-linux-gnueabi-pkg-config --libs opencv`; 

을하지만 지금은 문제 수 :

[email protected]:/home/zero/Desktop# opencv_arm peopledetect.cpp 
compiling peopledetect.cpp 
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/ld: warning: liblapack.so.3gf, needed by /usr/arm-linux-gnueabi/lib/libcxcore.so, not found (try using -rpath or -rpath-link) 
/tmp/ccDzUCLJ.o: In function `main': 
/home/zero/Desktop/peopledetect.cpp:49: undefined reference to `cv::HOGDescriptor::setSVMDetector(cv::_InputArray const&)' 
/home/zero/Desktop/peopledetect.cpp:84: undefined reference to  `cv::HOGDescriptor::detectMultiScale(cv::Mat const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, cv::Size_<int>, cv::Size_<int>, double, double, bool) const' 
/tmp/ccDzUCLJ.o: In function `cv::Mat::operator=(cv::Mat const&)': 
/usr/include/opencv2/core/mat.hpp:317: undefined reference to `cv::Mat::copySize(cv::Mat  const&)' 
/tmp/ccDzUCLJ.o: In function `cv::Mat::release()': 
/usr/include/opencv2/core/mat.hpp:382: undefined reference to `cv::Mat::deallocate()' 
/tmp/ccDzUCLJ.o: In function `_InputArray<float>': 
/usr/include/opencv2/core/mat.hpp:1108: undefined reference to `vtable for cv::_InputArray' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgelsd_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dpotrf_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dpotri_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dsyevr_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgesv_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dpotrs_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgetri_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgels_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgesv_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgetrf_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgetrf_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgels_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `spotrf_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgelsd_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgesdd_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `spotri_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `ssyevr_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `dgesdd_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `spotrs_' 
/usr/arm-linux-gnueabi/lib/libcxcore.so: undefined reference to `sgetri_' 
collect2: ld returned 1 exit status 
Output file => peopledetect 

답변

0

나는이 안내서를 따르지만 "lnclud opencv 배포판의 루트에있는 "e/opencv2"디렉토리가 비어 있습니다. 그래서 사실 라이브러리가 있지만 헤더가 없습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

UPD : 나는 조금 더 조심 그 후 프로그램을 컴파일 않았다 방법 http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8

관련 문제