交叉编译opencv app,未定义引用

时间:2022-08-16 04:51:01

I'm trying to cross compile a really simple OpenCV app for ARM platform from Ubuntu 14.04

我正在尝试从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);
}

I try to compile like this

我尝试像这样编译

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

But I get the error

但是我得到了错误

/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

These should be opencv_core which I've linked.

这些应该是我链接的opencv_core。

The includes and libraries were built and installed using CMake (from the OpenCV 3.0.0.zip), and they're definitely there, I can see them!

包含和库是使用CMake(来自OpenCV 3.0.0.zip)构建和安装的,它们肯定存在,我可以看到它们!

Help please, why is this happening?

请帮忙,为什么会这样?

1 个解决方案

#1


0  

Maybe you can try to add all -lopencv_xxx after:

也许您可以尝试在以下后添加所有-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

#1


0  

Maybe you can try to add all -lopencv_xxx after:

也许您可以尝试在以下后添加所有-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