OpenCV 4 for Arch based Linux distros
Installation
Install OpenGL extensions for GTK+ , hdf5 and vtk:
$ sudo pacman -S gtkglext hdf5 vtk
Install build-essential equivalent in Arch Linux, base-devel, and pkg-config:
$ sudo pacman -S base-devel pkg-config
Install OpenCV and OpenCV Samples:
$ sudo pacman -S opencv opencv-samples
Check the version of OpenCV to see if its correcly installed:
$ pkg-config --modversion opencv4
Locate pkgconfig and set the pkg-config path in /etc/bash.bashrc:
$ echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig" | sudo tee --append /etc/bash.bashrc
Write a config file that helps ldconfig locate the OpenCV libraries:
$ echo "/usr/include/opencv4" | sudo tee --append /etc/ld.so.conf.d/opencv4.conf
Creates the links
$ sudo ldconfig -v
Compiling with Makefile
In the same directory of the .cpp create a file called Makefile with the following code:
CFLAGS = `pkg-config --cflags opencv4`
LIBS = `pkg-config --libs opencv4`
% : %.cpp
g++ $(CFLAGS) $(LIBS) -o $@ $<
To compile:
$ make program-name
To run:
$ ./program-name