You are not logged in.

#1 2019-11-03 01:05:18

dmidge
Member
Registered: 2015-04-04
Posts: 68

Programming using OpenCV on Archlinux

Hi,


I am trying to do a small Opencv program on C++. For that, I am using the Eclipse CDT IDE, that compiles using g++. I have the opencv package installed through pacman.

Whenever I want to import header, I should have all the header files in /usr/local/include/, but in my case, it is empty. However, I find all the headers in /usr/include/opencv4.
When it comes to the libraries, to link, I can't make it work... I should get everything in /usr/local/lib but I don't. It is empty. I am replacing it by /usr/lib, where I have /usr/lib/libopencv_core.so.
Is it correct? If so, why can't I make it work?

Also, I tried pkg-config:

% pkg-config --libs opencv
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
Package 'opencv', required by 'virtual:world', not found

Thanks!
Cheers,

Offline

#2 2019-11-03 01:10:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Programming using OpenCV on Archlinux

$ pacman -Ql opencv | grep pc$
opencv /usr/lib/pkgconfig/opencv4.pc

$ pkg-config --libs opencv4
-lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_highgui -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_videoio -lopencv_viz -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core

But why would you expect system libraries or headers to be in /usr/local?

Also note:

$ pkg-config --cflags opencv4
-I/usr/include/opencv4

Last edited by Trilby (2019-11-03 01:11:49)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2019-11-04 01:19:09

dmidge
Member
Registered: 2015-04-04
Posts: 68

Re: Programming using OpenCV on Archlinux

Hi @Trilby,

Thanks for your answer!
I was indeed not expecting it in local. But for some reason, all the documentation that I found was in there. I guess I found everything in the most logical place.
But thanks to your answer, I was able to compile. The libraries to include where directly the names in the output of

pkg-config --libs opencv4

.

But I guess that I am not too familiar with the way shared libraries work on Linux. What is the *.pc file for? And is there a quick documentation that you would recommend me?

Thanks again!
Cheers.

Offline

#4 2019-11-04 01:47:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Programming using OpenCV on Archlinux

You should not explicitly list the libraries.  Just use pkgconf/pkg-config in your makefile, e.g.

CFLAGS   += $(pkgconf --cflags opencv4)
LDLIBS    += $(pkgconf --libs opencv4)

...

But for general information about pkgconf/pkg-config, google.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB