我正在尝试从Ubuntu 14.04交叉编译一个非常简单的ARM平台OpenCV应用程序
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>
using namespace cv;
using namespace std;
main(int argc, char *argv[])
{
Mat img = imread("/home/linaro/Desktop/test.jpg", CV_LOAD_IMAGE_COLOR), grey_img;
if(!(img.data))
{
printf("cannot read image data");
exit(1);
}
cvtColor(img, grey_img, CV_BGR2GRAY);
imwrite("/home/linaro/Desktop/grey_test.jpg", grey_img);
}
我尝试像这样编译
arm-linux-gnueabi-g++ opencv_grey.cpp -o grey -I /home/me/c_projects/arm_platform/armcv_build/install/include/opencv -I /home/me/c_projects/arm_platform/armcv_build/install/include/opencv2 -L /home/me/c_projects/arm_platform/armcv_build/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui
但是我收到了错误
/tmp/ccdN4trw.o: In function `main':
opencv_grey.cpp:(.text+0x84): undefined reference to `cv::imread(std::string const&, int)'
opencv_grey.cpp:(.text+0x168): undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
这些应该是我链接的opencv_core。
包含和库是使用CMake(来自OpenCV 3.0.0.zip)构建和安装的,它们肯定存在,我可以看到它们!
请帮助,为什么会发生这种情况?
答案 0 :(得分:0)
也许您可以尝试在以下后添加所有-lopencv_xxx
:
arm-linux-gnueabi-g++ opencv_grey.cpp -o grey -I /home/me/c_projects/arm_platform/armcv_build/install/include/opencv -I /home/me/c_projects/arm_platform/armcv_build/install/include/opencv2 -L /home/me/c_projects/arm_platform/armcv_build/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui