OpenCV找不到highgui

时间:2014-03-27 21:06:29

标签: c++ opencv

我试图编译一个opencv文件,但似乎找不到highgui库

g++ -O2 -W -Wall -lhighgui tracking.cc -o tracking
/usr/bin/ld: cannot find -lhighgui
collect2: error: ld returned 1 exit status

知道如何解决这个问题吗?

我试过

updatedb
ldconfig
g++ -O2 -W -Wall -L/usr/lib/libopencv_highgui.so tracking.cc -o tracking

但似乎没有任何效果......

修改 发出pkg-config --libs --cflags 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_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl

发出

g ++ pkg-config --libs --cflags opencv -L / usr / local / lib / tracking.cc -o tracking

返回

/tmp/ccrc3n9d.o:在函数main': tracking.cc:(.text+0x53): undefined reference to cvCreateCameraCapture'     tracking.cc:(.text+0x95):未定义引用cvNamedWindow' tracking.cc:(.text+0xb1): undefined reference to cvMoveWindow'     tracking.cc:(.text+0xc5):未定义引用cvNamedWindow' tracking.cc:(.text+0xe1): undefined reference to cvMoveWindow'   ......

不知道!

1 个答案:

答案 0 :(得分:0)

好的找到了解决方案,只需将我的代码放在opencv的samples目录中并调用buildall.sh

单独注意,不建议使用opencv,而是每次手动链接最好。