打开简历无法编译

发布于 2024-12-27 10:04:24 字数 885 浏览 0 评论 0原文

我正在尝试编译一些 opencv 代码,但失败了。我很确定我已经包含了这些库,但它仍然具有对函数的未定义引用。

我正在运行这个命令:

gcc -lhighgui -lcvaux -lcxcore -I /usr/local/include/opencv/ -L /usr/local/lib/ -o hello_world hello_world.c

并得到此结果

foo.cpp:(.text._ZN3Foo3barEv[Foo::bar()]+0x1f):对“cvLoadImage”的未定义引用

foo.cpp:(.text._ZN3Foo3barEv[Foo::bar()]+0x2d):对“cvWaitKey”的未定义引用

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "opencv/cv.h"
#include "opencv/highgui.h"


class Foo{
    public:
        void bar(){
          IplImage* img = 0;

      img=cvLoadImage("C:/.../Pictures/image.jpg");  


      cvWaitKey(0);


      system("PAUSE");
    }
};

extern "C" {
    Foo* Foo_new(){ return new Foo(); }
    void Foo_bar(Foo* foo){ foo->bar(); }
}

I'm trying to compile some opencv code, but it is failing. I'm pretty sure I have the libraries included but it still has undefined references to the functions.

I'm running this command:

gcc -lhighgui -lcvaux -lcxcore -I /usr/local/include/opencv/ -L /usr/local/lib/ -o hello_world hello_world.c

and get this result

foo.cpp:(.text._ZN3Foo3barEv[Foo::bar()]+0x1f): undefined reference to `cvLoadImage'

foo.cpp:(.text._ZN3Foo3barEv[Foo::bar()]+0x2d): undefined reference to `cvWaitKey'

with this code:

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "opencv/cv.h"
#include "opencv/highgui.h"


class Foo{
    public:
        void bar(){
          IplImage* img = 0;

      img=cvLoadImage("C:/.../Pictures/image.jpg");  


      cvWaitKey(0);


      system("PAUSE");
    }
};

extern "C" {
    Foo* Foo_new(){ return new Foo(); }
    void Foo_bar(Foo* foo){ foo->bar(); }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文