Compile OpenCV4

twitter logo github logo ・1 min read

Since OpenCV4 does not generata .pc file by default, we need to compile it from source and turn ont the OPENCV_GENERATE_PKGCONFIG option if other programs need the pkg-config file.

Another problem I encountered is a number of errors similar to undefined reference to TIFFReadRGBAStrip@LIBTIFF_4.0. To solve that, the BUILD_TIFF option needs to be turned on.

And following is the script for compilation and installation.

wget https://github.com/opencv/opencv/archive/4.1.0.zip
unzip opencv-4.1.0.zip
cd opencv-4.1.0
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_TIFF=ON
sudo make -j`nproc`
sudo make install
twitter logo DISCUSS
Classic DEV Post from Feb 5

Overcoming the Tutorial Gap and Making Your Own Software

How to take the next step in the software development journey.

Gabriel Wu profile image
A writer. Writing academic papers, blogs, codes, documents, essays, novels, poems, and translations.

Don't ghost on us ❤️

Sign Up