Skip to content

crosstyan/opencv_minimum_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple OpenCV demo

Building it in Linux and macOS is trivial thanks to package manager. However, building it in Windows is a little bit tricky.

Don't forget to clone the submodules

git submodule update --init --recursive

Windows Build

When I say "install" I also mean "add to your PATH environment variable".

You DO NOT NEED MSYS2 since no MingGW should be used.

If you see clang: warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt [-Wmsvc-not-found] when compiling then you should check if Visual Studio Build Tools have been installed correctly.

You could still try mingw-w64-x86_64-opencv or mingw-w64-ucrt-x86_64-opencv in MSYS2 in a MinGW environment if you're targeting MinGW but they are not binary compatible with MSVC.

OpenCV Windows Installation

Run the executable and extract the files to a folder. I prefer C:\opt\opencv.

opencv
├── build
├── LICENSE_FFMPEG.txt
├── LICENSE.txt
├── README.md.txt
└── sources

Add C:\opt\opencv\build\x64\vc16\bin to your PATH environment variable. PATH acts like LD_LIBRARY_PATH in Linux here so missing this step will cause dll not found error. In my machine even no error was raised so I have to check the dynamic linking manually using lucasg/Dependencies.

See also

Build walkthrough

mkdir build
cd build
cmake -DOpenCV_DIR=C:/opt/opencv/build/x64/vc16/lib -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang.exe" -G Ninja ..
ninja -j (Invoke-Expression [Environment]::ProcessorCount)

Visual Studio Code

See .vsode/settings.windows.jsonc. Change it to .vscode/settings.json to be your workspace configuration.

Linux Build

Install dependencies

Ubuntu/Debian

sudo apt install build-essential cmake ninja-build
sudo apt install libopencv-dev

Arch Linux

pacman -S base-devel cmake ninja
pacman -S opencv

Build

This is a typical out-of-source build. Trivially, you can run the following commands:

mkdir build
cd build
cmake .. -G Ninja
ninja -j$(nproc)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks