我正在尝试编译一些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(); }
}