1、问题:使用arm-linux-gcc交叉编译opencv的源程序时遇到以下错误:
test.cpp:1:16: error: cv.h: No such file or directory
test.cpp:2:21: error: highgui.h: No such file or directory
test.cpp: In function 'int main()':
test.cpp:6: error: 'IplImage' was not declared in this scope
test.cpp:6: error: 'test' was not declared in this scope
test.cpp:7: error: 'cvLoadImage' was not declared in this scope
test.cpp:10: error: 'stderr' was not declared in this scope
test.cpp:10: error: 'fprintf' was not declared in this scope
test.cpp:15: error: 'stderr' was not declared in this scope
test.cpp:15: error: 'fprintf' was not declared in this scope
test.cpp:18: error: 'cvNamedWindow' was not declared in this scope
test.cpp:20: error: 'cvWaitKey' was not declared in this scope
test.cpp:21: error: 'cvDestroyWindow' was not declared in this scope
我使用的编译命令是: arm-linux-g++ test.cpp -o test -I /work/projects/opencv-2.4.10/include -L /work/projects/opencv-2.4.10/lib -lcv -lcxcore -lhighgui -lpthread
我已经把/work/projects/opencv-2.4.10/include/opencv文件夹、/work/projects/opencv-2.4.10/include/opencv2文件夹和/work/projects/opencv-2.4.10/lib下的动态库,全都拷贝到/usr/local/arm/4.3.2/arm-none-linux-gnueabi下面对应的目录下了。 但是还是有这样的问题,已经弄了很久了,一直没有成功。
我是参考的移植教程:http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8
2.环境:
交叉编译工具链所在 /usr/local/arm/4.3.2/
编译的平台的是:Ubuntu12.04
版本:OpenCV2.4.10
arm-linux-gcc4.3.2
5 个解决方案
#1
头文件找不到:先查找一个这个文件是否存在;如果存在,然后再看相应的路径是否增加到 include 的声明中。
#2
未定义的错误,可以查代码,看看是否定义?如果定义了,则可能是对应的头文件没有正确的 include
#3
快来看看啦,向大神们学习,共同进步!
#4
cv.h和highgui.h都已经定义了,这是我的代码:
#include <cv.h>
#include <highgui.h>
using namespace std;
int main()
{
IplImage * test;
test = cvLoadImage("/mnt/workroom/test_BB.jpg");//图片路径
if(!test)
{
fprintf(stderr, "Can not load picture./n");
}
else
{
fprintf(stderr, "Load picture successfully./n");
//return 0;
}
cvNamedWindow("test_demo", 1);
//cvShowImage("test_demo", test);
cvWaitKey(0);
cvDestroyWindow("test_demo");
//cvReleaseImage(&test);
return 0;
}
#5
头文件也都存在:
/usr/local/arm/4.3.2/arm-none-linux-gnueabi/include/opencv# ls
cvaux.h cv.h cvwimage.h cxcore.hpp cxmisc.h ml.h
cvaux.hpp cv.hpp cxcore.h cxeigen.hpp highgui.h
相应的路径,是添加到 /usr/local/arm/4.3.2/arm-none-linux-gnueabi下面对应的目录下 吗? 这个已经添加了
#1
头文件找不到:先查找一个这个文件是否存在;如果存在,然后再看相应的路径是否增加到 include 的声明中。
#2
未定义的错误,可以查代码,看看是否定义?如果定义了,则可能是对应的头文件没有正确的 include
#3
快来看看啦,向大神们学习,共同进步!
#4
cv.h和highgui.h都已经定义了,这是我的代码:
#include <cv.h>
#include <highgui.h>
using namespace std;
int main()
{
IplImage * test;
test = cvLoadImage("/mnt/workroom/test_BB.jpg");//图片路径
if(!test)
{
fprintf(stderr, "Can not load picture./n");
}
else
{
fprintf(stderr, "Load picture successfully./n");
//return 0;
}
cvNamedWindow("test_demo", 1);
//cvShowImage("test_demo", test);
cvWaitKey(0);
cvDestroyWindow("test_demo");
//cvReleaseImage(&test);
return 0;
}
#5
头文件也都存在:
/usr/local/arm/4.3.2/arm-none-linux-gnueabi/include/opencv# ls
cvaux.h cv.h cvwimage.h cxcore.hpp cxmisc.h ml.h
cvaux.hpp cv.hpp cxcore.h cxeigen.hpp highgui.h
相应的路径,是添加到 /usr/local/arm/4.3.2/arm-none-linux-gnueabi下面对应的目录下 吗? 这个已经添加了