奇怪的opencv.pc(pkg-config)文件

时间:2012-07-12 00:41:05

标签: ubuntu opencv

我在Ubuntu 12.04 64bit上构建了opencv。如果我发出以下命令,我可以链接到opencv库:

g++ `pkg-config opencv --cflags` my_code.cpp  -o my_code `pkg-config opencv --libs` 

但是,如果我发出以下命令:

gcc -g -O2 -W -Wall -Wno-unused -Wno-multichar  -o main main.o -lcxcore -lcv -lhighgui -lcvaux 

我明白了:

/usr/bin/ld: cannot find -lcxcore
/usr/bin/ld: cannot find -lcv
/usr/bin/ld: cannot find -lhighgui
/usr/bin/ld: cannot find -lcvaux
collect2: ld returned 1 exit status

解决我发出的问题:

pkg-config --libs opencv 

得到了:

/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

我想这解释了这个问题,但我不明白为什么opencv.pc不包含像通常的.pc文件这样的库位置的简写“-llib”格式。任何想法??

1 个答案:

答案 0 :(得分:0)

您需要包含pkg-config为您提供的库头的位置

pkg-config opencv --cflags

对我来说,输出是

  

-I / usr / local / include / opencv -I / usr / local / include

如果你添加它,它应该可以正常工作