打开简历无法编译
我正在尝试编译一些 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论