Why does pkg-config --libs opencv return library locations and not the libraries themselves?

StackOverflow https://stackoverflow.com/questions/16443751

  •  14-04-2022
  •  | 
  •  

Question

I am trying to compile a c++ program that incorporates OpenCV. I want to use pkg-config to make the compilation easier. However this does not work due to the fact that pkg-config -libs opencv returns the library locations and not the libraries themselves. I got:

/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
...

While I am expecting something like

-L/usr/local/include/ -lopencv_contrib -lopencv_features2d ...

Have I screwed something up? If not, why has this happened? And can it be fixed?

Was it helpful?

Solution

The output of the pkg-config is correct.

The GNU linker (ld) (I don't know if others too) allows you to write the libraries with their full path, without any -L or -l, in addition to the usual -L and -l options.

The error must be in some other place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top