How to build opencv for Universal Windows Platform (UWP)

End to end steps to build opencv for universal windows platform (uwp)

Md. Mehedi Hasan
3 min readJun 27, 2018

To build opencv for universal windows platform need to follow several steps.

Prerequisites:

  • Windows 10
  • Visual Studio ≥ 2015
  • Latest CMAKE

Setting Up Environment

Build Instruction

  • Open CMake GUI. Is should show the window as screenshot below.
  • CMake initial window.Specify opencv source directory. After extract opencv for winpack on your machine there should have 2 folders under root directory as build and source.
    “Where is the source code:” please specify opencv source folder.
    “Where to build the binaries:” please specify opencv build folder.
  • Then please click on configure button.It should show the screen like the following screenshot. You can specify generator for project. There are several options, for example: Visual Studio 15 2017 Win64, Visual Studio 15 2017, Visual Studio 15 2017 ARM etc. We need to build all three generator to support all platforms.
  • CMake configuration for buildClick on “Specify options for cross-compiling”. Then click on next button as screenshot below.
  • CMake specify options for cross compiling. Write Operating System as “WindowsStore” and Version as “10.0” for now. It may change after Windows version changes later. Then click on finish button. It’ll start configure libraries.
  • CMake specify operating system and version as shown in the screenshot below.
  • After configuration completed, you should show the windows like the following screenshot.
  • Now please make sure you’ve checked BUILD_opencv_world as the following screenshot. Then click on the Generate button. BUILD_opencv_world is not mandatory but for our project built single dll and lib to access all opencv api. If we build all we’ve to make sure we’ve collected all dlls and libs and managed them carefully.
  • After generation completed it’ll create solution and project inside build directory. For example it built solution and projects inside D:/Downloads/cv_build. You should see OpenCV.sln inside directory. Please open solution with Visual Studio. In my case used Visual Studio 2017 to build. Under CMakeTargets you should see a project named INSTALL (Windows Store 10.0) as shown in the screenshot below.
  • Build this project with Debug and Release configuration. After successful build it should build libs(.lib), binaries(dlls) and header files for Universal Windows platform under install directory as screenshot below. This screenshot shows the build folder for x64 platform. Follow these process to create build for x86 and ARM too.

That’s it, now opencv library and dlls are ready to use on your Universal Windows Platform application.

--

--