我已经安装了 openCV 库,但仍然收到错误
$ g++ -I /usr/include/opencv/ -L -lcxcore -lhighgui hello.cpp -o hello
/tmp/ccjjrbXr.o: In function cvLoadImage main':
hello.cpp:(.text+0x2d): undefined reference to
'
collect2: ld返回 1 个退出状态
当我检查库的路径时,我得到
$ pkg-config --libs opencv
-lml -lcvaux -lhighgui -lcv -lcxcore
我写了一个非常简单的程序来测试它:
enter code here
#include< cv.h>
#include< highgui.h> /* required to use OpenCV's highgui */
#include< stdio.h>
int main() {
IplImage* img = 0;
printf("Hello\n");
img = cvLoadImage("lena.jpg", 0 );
}
我的安装有问题,但我真的无法弄清楚。任何指导将不胜感激!谢谢
当我运行时:
$ pkg-config --cflags --libs opencv
-I/usr/local/include/opencv -I/usr/local/include
/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so
/usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so
/usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so
/usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so
/usr/local/lib/libopencv_ts.so /usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so
但是当我运行时:
$ g++ 'pkg-config --cflags --libs opencv' display_image.cpp
g++: error: pkg-config --cflags --libs opencv: No such file or directory
OpenCV 似乎已安装,但问题仍然存在。