Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
Tutorial: Installation from source for Windows with Mingw-w64

In this tutorial you will learn how to install ViSP from source on Windows 8.1 with Mingw-w64. These steps have been tested:

  • on Windows 8.1 (64 bit), with CMake 3.3.2 and Mingw-w64 - GCC for Windows 64 & 32 bits
  • on windows 10 (64 bit), with CMake 3.13.1 and Mingw-w64 - GCC for Windows 64 & 32 bits.
Note
Concerning ViSP installation, we provide also other Tutorials.

Install prerequisities

Mingw-w64

Mingw-w64 could be found following http://mingw-w64.org/doku.php/download. From that page, click on download "Win-builds" that will bring you to the page http://mingw-w64.org/doku.php/download/win-builds from where you can access to http://win-builds.org/doku.php/download_and_installation_from_windows. Here simply download and run the package manager, in our case we downloaded win-builds-1.5.0.exe file.

  • Once downloaded, double click on the the exe file. It will open an installation window.
  • Select x86_64 and MinGW installation folder C:\mingw as in the following image:
    img-mingw64-installer-started.jpg
    Note
    It you want to install MinGW in an other folder, you have to set MINGW_DIR environment variable to your installation location in order to allow CMake to detect 3rd party libraries that come with MinGW installer. Fo example, if you install MinGW in C:\folder\mingw-w64, setting MINGW_DIR is simply done running in a cmd Command Prompt:
    C:\> setx MINGW_DIR "C:\folder\mingw-w64"
    C:\> exit
  • Click on "OK" button. It will open an other window:
    img-mingw64-installer-process.jpg
  • Where you can click on "Process" button to start the installation
  • A window shows the progression of the installation. When all the packages are installed you can close all the installation windows.
  • To finish the installation, just add C:\mingw\bin folder to the Path variable. To this end open cmd Comand Prompt and do the following:
    C:\> setx Path "%Path%;C:\mingw\bin"
    C:\> exit
  • To check that C:\mingw\bin was added, open a new cmd Command Prompt, and run:
    C:\> echo %Path%

CMake

CMake could be download from http://www.cmake.org. Download the latest release for Windows win64-x64 platform (at the time this tuto was written it was the file cmake-3.13.1-win64-x64.msi). To install just double click on the msi file.

Git

Install Git for Windows from https://git-for-windows.github.io/. This installation allows then to use git in a cmd Command Prompt.

Create a workspace

If not already done, create a workspace that will contain all ViSP source, build, data set and optional 3rd parties. This workspace is here set to C:\visp-ws folder, but it could be set to any other location.

To create the workspace, open a cmd Command Prompt (a fast way to launch this window is to press the Win + R keys on your keyboard. Then, type cmd or cmd.exe and press Enter or click/tap OK) and run the following to create a workspace environment var named VISP_WS:

C:\> setx VISP_WS "C:\visp-ws"
C:\> exit

Open a new cmd Command Prompt and create the corresponding folder

C:\> mkdir %VISP_WS%
C:\> exit

Quick ViSP installation

In this section, we give minimal instructions to build ViSP from source just to try ViSP without entering in Advanced ViSP installation.

  • Open a new cmd Command Prompt and get ViSP source code in the workspace
    C:\> cd %VISP_WS%
    C:\> git clone https://github.com/lagadic/visp.git
  • Create a build directory
    C:\> mkdir %VISP_WS%\visp-build-mingw
    C:\> cd %VISP_WS%\visp-build-mingw
  • Run CMake in build directory (here the generator is chosen for Visual Studio 15 2017 and 64 bits hardware):
    C:\> cmake -G "MinGW Makefiles" %VISP_WS%\visp
  • Build and install ViSP (installation doesn't need administrator privileges)
    C:\> cmake --build . --config Release --target install
  • ViSP is now installed in %VISP_WS%\visp-build-mingw\install folder
  • Modify the Path var to add %VISP_WS%\visp-build-mingw\install\x64\mingw\bin corresponding to the path to ViSP libraries.
  • Set VISP_DIR var to help CMake to find ViSP as a 3rd party
    C:\> setx VISP_DIR "%VISP_WS%\visp-build-mingw\install"
    C:\> exit
Note
Since setx command is not able to handle a var that has more than 1024 characters (which could be the case of Path var), to modify Path environment variable do the following:
  1. Open the Start Search, type in "env", and choose "Edit environment variables for your account"
  2. Click the "Environment Variables..." button
  3. Under the "User Variables" section (the upper half), find the row with "Path" in the first column, and click edit
  4. The "Edit environment variable" UI will appear.
  5. Click "New" button to add a new line with %VISP_WS%\visp-build-mingw\install\x64\mingw\bin

To have a trial, just jump to Install ViSP data set before running some binaries that you just build or jump to Next tutorial. You can later come back to the Advanced ViSP installation.

Advanced ViSP installation

Install 3rd parties

ViSP is interfaced with several 3rd party libraries. The complete list is provided here. We recommend to install OpenCV 3rd party in the workspace.

OpenCV 3rd party

1. Get OpenCV

First you have to get OpenCV:

  • From http://opencv.org/releases.html download the latest OpenCV for Windows. In our case we got opencv-4.0.0-vc14_vc15.exe Win pack installer. The same procedure could be applied with the previous OpenCV 3.4.0 release downloading opencv-3.4.0-vc14_vc15.exe.
  • Extract the content of the archive in your workspace %VISP_WS%.
    img-win10-extract-opencv.png
  • The installer extract all the material in %VISP_WS%\opencv.
  • We strongly recommend to rename this folder to a name that contain OpenCV version like %VISP_WS%\opencv-4.0.0.
Note
OpenCV 4.0.0 win pack installer contains prebuild OpenCV libraries build with Visual Studio 14 2015 Win64 (vc14) and Visual Studio 15 2017 Win64 (vc15) but there is no build for MinGW. That's why you need to build yourself OpenCV from source and install the libraries in %VISP_WS%\opencv-4.0.0\build\x64\mingw.

2. Configure, build and install OpenCV from source

  • Open a cmd Command Prompt and create a build folder
    C:\> cd %VISP_WS%\opencv-4.0.0
    C:\> mkdir build-mingw
    C:\> cd build-mingw
  • Run CMake in build directory and set the install dir to VISP_WS%\opencv-4.0.0\build:
    C:\> cmake -G "MinGW Makefiles" ..\sources -DWITH_MSMF=OFF -DCMAKE_INSTALL_PREFIX=%VISP_WS%\opencv-4.0.0\build
  • Build and install OpenCV for MinGW (installation doesn't need administrator privileges)
    C:\> cmake --build . --config Release --target install
  • OpenCV is now installed in %VISP_WS%\opencv-4.0.0\build folder
  • Modify the Path var to add %VISP_WS%\opencv-4.0.0\build\x64\mingw\bin corresponding to the path to OpenCV libraries.
  • Set OpenCV_DIR var to help CMake to find ViSP as a 3rd party
    C:\> setx OpenCV_DIR "%VISP_WS%\opencv-4.0.0\build"
    C:\> exit
Note
Depending on OpenCV version you may encounter the following issues, for which we propose work arrounds; windres.exe invalid option --W, Build error in cap_dshow.cpp, OpenCV build error: struct has virtual functions and accessible non-virtual destructor, OpenCV build error: cannot build with tiff support, or OpenCV link error: cannot find -lRunTmChk.

3. Complete OpenCV installation

Now you have to complete OpenCV installation setting some environment vars:

  • In order that ViSP detects OpenCV you have to set OpenCV_DIR environment variable. Start up a cmd Command Prompt and enter:
    C:\> setx OpenCV_DIR "%VISP_WS%\opencv-4.0.0\build"
    C:\> exit
    where %VISP_WS%\opencv-4.0.0\build is where you have installed OpenCV. Inside this folder you should have a file named OpenCVConfig.cmake.
  • You have also to add the location of OpenCV libraries corresponding to MinGW usage in the Path environment variable. Open the "Edit environment variable" UI, and modify Path to add a new line with %VISP_WS%\opencv-4.0.0\build\x64\mingw\bin.

Get ViSP source code

There are different ways to get ViSP source code.

  • You can download the latest release as a zip or a tarball. Once visp-x.y.z.tar.gz or visp-x.y.z.zip is downloaded, uncompress the file in %VISP_WS%\visp\visp-x.y.z using for axample WinRAR.
  • You can also download a daily snapshot. Once visp-snapshot-yyyy-mm-dd.tar.gz is downloaded, uncompress the file in %VISP_WS%\visp\visp-x.y.z using for axample WinRAR.
  • Or you get the cutting-edge ViSP from GitHub repository using the git command line tool:
    C:\> cd %VISP_WS%
    C:\> git clone https://github.com/lagadic/visp.git

We suppose now that ViSP source is in %VISP_WS%\visp.

Configure ViSP from source

The goal of the configuration step is now to use CMake to produce a Visual Studio C++ solution file that will be located in %VISP_WS%/visp-build-mingw.

  • Launch CMake (cmake-gui) and complete the source code and binaries location as in the next image.
    img-cmake-win10-mingw-visp-launch.png
  • Click then on "Configure" button.
    img-cmake-win10-mingw-visp-create-folder.png
  • Click on "Yes" to create the %VISP_WS%/visp-build-mingw folder.
  • Select then your compiler "MinGW Makefiles" and click on "Finish" button.
    img-cmake-win10-mingw-makefiles.png
  • This will start CMake configuration. As shown in the next image, OpenCV, GDI (Graphical Device Interface), libjpeg, libpng, pthread and libxml2 3rd party are automatically detected.
    img-cmake-win10-mingw-visp-config.png
    Note
    If OpenCV is not detected, you may encounter the following issue OpenCV not detected with Mingw build.
    Installation folder is set to %VISP_WS%/visp-build-mingw/install. If you want to change the installation folder to C:/Program Files (x86)/ViSP, make sure that you have administrator privileges to write in that folder before modifying CMAKE_INSTALL_PREFIX.
  • Click then on "Configure" button. All the red lines should disappear.
    Note
    The default configuration lead to the creation of a shared library (with .dll extension). This is the default configuration that is recommended. If you want to create rather a static library (with .lib extension) you have to uncheck the BUILD_SHARED_LIBS option to disable DLL creation.
  • To finish the configuration, click on "Generate" button.
    img-cmake-win10-mingw-visp-generate.png
  • Once the generation is done, in %VISP_WS%/visp-build-mingw folder you have the Makefile file that will be used by MinGW to build the whole project.

Build and install ViSP libraries

  • To build ViSP, open a cmd Command Prompt, change to %VISP_WS%\visp-build-mingw folder and run mingw32-make:
    C:\> cd %VISP_WS%\visp-build-mingw
    C:\> mingw32-make -j4
  • Now to install ViSP, in the same cmd Command Prompt run:
    C:\> mingw32-make -j4 install
  • At the end, in %VISP_WS%/visp-build-mingw/install/x64/mingw/bin folder you will find ViSP DLL libraries corresponding to the build modules.
    Note
    When CMAKE_BUILD_TYPE is set to Debug, the library names are suffixed by "d".

Set Path environment var

Modify the Path var to add the path to ViSP dll libraries. To this end open the "Edit environment variable" UI, and modify Path to add a new line with %VISP_WS%\visp-build-mingw\install\x64\mingw\bin.

Set VISP_DIR environment var

In order to ease ViSP detection by CMake when ViSP is used as a 3rd party in an external project, like the one described in the Tutorial: How to create and build a CMake project that uses ViSP on Unix or Windows, you may set VISP_DIR environment variable with the path to the VISPConfig.cmake file:

C:\> setx VISP_DIR "%VISP_WS%\visp-build-mingw\install"
C:\> exit

Install ViSP data set

Some ViSP examples and tests require data (images, video, models) that are not part of ViSP source code but available in a separate archive named visp-images-x.y.z.zip. This archive could be downloaded from http://visp.inria.fr/download page. We provide here after the way to install these data if you want to run ViSP examples or tests. Note that ViSP tutorials are not using ViSP data set.

  • Download visp-images-3.2.0.zip from https://visp.inria.fr/download and uncompress it in your workspace %VISP_WS%.
    img-win10-visp-images.png
  • ViSP examples and tests are able to detect automatically the location of the requested data if you position an environment variable called VISP_INPUT_IMAGE_PATH. In our case, this variable should be set to %VISP_WS%\visp-images-3.2.0. Open a cmd Command Prompt and run
    C:\> setx VISP_INPUT_IMAGE_PATH %VISP_WS%\visp-images-3.2.0
    C:\> exit
  • From now, you can try to run ViSP examples and tests. For example, if you want to run %VISP_WS%\visp-build-mingw\example\device\display\displayGDI.exe, open a cmd Command Prompt, enter in the right folder and run:
    C:\> cd %VISP_WS%\visp-build-mingw\example\device\display
    C:\> displayGDI.exe
    A click to close the windows...
    A click to display a cross...
    Cross position: 392, 306
    A click to exit the program...
    Bye

Tips and tricks

How to take into account a newly installed 3rd party

Since all 3rd parties are optional you may have started to install only some of them. Imagine that you just installed a new third-party, or that you upgraded the version of this 3rd party. The next step is to go back to the build folder, configure ViSP with CMake to detect the newly installed third-party library and build again ViSP. This could be achieved with:

$ cd $VISP_WS/visp-build-mingw
$ cmake ../visp

Here you can check the content of the ViSP-third-party.txt file and see if the newly installed 3rd party is well detected.

Finally, you need to rebuild ViSP with:

$ mingw32-make

How to uninstall ViSP

After ViSP installation, you can remove installed material using:

$ cd $VISP_WS/visp-build-mingw
$ mingw32-make uninstall

How to build only ViSP libraries

If you want to build only ViSP modules libraries, nor the examples, tutorials and tests:

$ cd $VISP_WS/visp-build-mingw
$ mingw32-make visp_modules

How to build a ViSP specific module

If you want to build a given module and all the dependencies:

$ cd $VISP_WS/visp-build-mingw
$ mingw32-make visp_<module_name>

For example to build the model-based tracker module named mbt, run:

$ cd $VISP_WS/visp-build-mingw
$ mingw32-make visp_mbt

Which are the 3rd party libraries that are used in ViSP ?

To see which are the optional 3rd parties that are found during the configuration stage and that will be used by ViSP during the build you can have a look to the text file named ViSP-third-party.txt and located in $VISP_WS/visp-build. We provide hereafter an example of a possible content of this file that contains also build info.

$ type $VISP_WS/visp-build/ViSP-third-party.txt
==========================================================
General configuration information for ViSP 3.2.0
Version control: 3.1.0-724-g285753ca6
Platform:
Timestamp: 2018-12-12T06:33:44Z
Host: Windows 10.0.15063 AMD64
CMake: 3.13.1
CMake generator: MinGW Makefiles
CMake build tool: C:/mingw/bin/mingw32-make.exe
Configuration: Release
C/C++:
Built as dynamic libs?: yes
C++ Compiler: C:/mingw/bin/g++.exe (ver 4.8.3)
C++ flags (Release): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -O3 -DNDEBUG
C++ flags (Debug): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -g
C Compiler: C:/mingw/bin/gcc.exe
C flags (Release): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -O3 -DNDEBUG
C flags (Debug): -Wall -Wextra -std=c++11 -fvisibility=hidden -msse2 -msse3 -mssse3 -g
Linker flags (Release):
Linker flags (Debug):
ViSP modules:
To be built: core gui imgproc io java_bindings_generator klt me sensor ar blob robot visual_features vs vision detection mbt tt tt_mi
Disabled: -
Disabled by dependency: -
Unavailable: java
Windows RT support: no
Python (for build): NO
Java:
ant: NO
JNI: C:/Program Files/Java/jdk1.8.0_144/include C:/Program Files/Java/jdk1.8.0_144/include/win32 C:/Program Files/Java/jdk1.8.0_144/include
Build options:
Build deprecated: yes
Build with moment combine: no
Mathematics:
Use Lapack/blas: no
Use Lapack (built-in): yes (ver 3.2.1)
Use Eigen3: no
Use OpenCV: yes (ver 4.0.0)
Use GSL: no
Simulator:
Ogre simulator:
\- Use Ogre3D: no
\- Use OIS: no
Coin simulator:
\- Use Coin3D: no
\- Use SoWin: no
\- Use SoXt: no
\- Use SoQt: no
\- Use Qt4: no
\- Use Qt3: no
Media I/O:
Use JPEG: yes (ver 90)
Use PNG: yes (ver 1.4.14)
\- Use ZLIB: yes (ver 1.2.8)
Use OpenCV: yes (ver 4.0.0)
Real robots:
Use Afma4: no
Use Afma6: no
Use Franka: no
Use Viper650: no
Use Viper850: no
Use aria (Pioneer): no
Use PTU46: no
Use Biclops PT: no
Use Virtuose: no
GUI:
Use X11: no
Use GTK: no
Use OpenCV: yes (ver 4.0.0)
Use GDI: yes
Use Direct3D: no
Cameras:
Use DC1394-2.x: no
Use CMU 1394: no
Use V4L2: no
Use directshow: no
Use OpenCV: yes (ver 4.0.0)
Use Flycapture: no
Use Pylon: no
RGB-D sensors:
Use Realsense: no
Use Realsense2: no
Use Kinect: no
\- Use libfreenect: no
\- Use libusb-1: no
\- Use pthread: yes
Use PCL: no
\- Use VTK: no
F/T sensors:
Use atidaq (built-in): no
Use comedi: no
Detection:
Use zbar: no
Use dmtx: no
Use AprilTag (built-in): yes (ver 0.9.8)
Misc:
Use Clipper (built-in): yes (ver 6.4.2)
Use XML2: yes (ver 2.9.2)
Optimization:
Use OpenMP: no
Use pthread: yes
Use pthread (built-in): no
Use cxx11: yes
cxx standard: 11
Documentation:
Use doxygen: no
Tests and samples:
Tests: yes
Demos: yes
Examples: yes
Tutorials: yes
Install path: C:/visp-ws/visp-build-mingw/install
==========================================================

Known issues

OpenCV endianness failure during CMake configuration

Note
This issue occurs with OpenCV 2.4.10, 2.3.0-beta and 2.3.0 releases.

If you encounter the following issue during CMake configuration

img-opencv-issue-test-big-endian.jpg

Edit %VISP_WS%\opencv-2.y.z\sources\CMakeLists.txt file, and line 464 replace:

test_big_endian(WORDS_BIGENDIAN)

by:

#test_big_endian(WORDS_BIGENDIAN)
set(WORDS_BIGENDIAN 0)

OpenCV build error: cannot build with tiff support

Note
This issue occurs with OpenCV 2.4.10, 2.3.0-beta and 2.3.0 releases.

If you encounter a build issue during libtiff build as given in the next image:

img-opencv-issue-tiff.jpg
  • Open CMake GUI on OpenCV, turn BUILD_TIFF=OFF and also WITH_TIFF=OFF
  • Click on "Configure" button, and then on "Generate" one.
  • Build again OpenCV using
    cd %VISP_WS%\opencv-2.y.z\sources\build-mingw
    C:\> mingw32-make

OpenCV link error: cannot find -lRunTmChk

Note
This issue occurs with OpenCV 2.3.0-beta and 2.3.0 releases.

The following image shows the link issue that may appear when building OpenCV with MinGW:

img-opencv-issue-ipp.jpg

A work arround is to configure OpenCV without ipp support turning WITH_IPP=OFF and then trying to build again.

OpenCV build error: struct has virtual functions and accessible non-virtual destructor

This error that occurs with OpenCV 3.0.0 during cap_dshow.cpp build is known and reported as an issue in https://github.com/Itseez/opencv/pull/5282/commits.

img-win8.1-mingw-opencv-issue-dtor.jpg
  • The fix consists in modifying modules/videoio/src/cap_dshow.cpp by adding near line 96:
    #ifdef __MINGW32__
    // MinGW does not understand COM interfaces
    #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
    #endif

OpenCV not detected with Mingw build

Note
This issue occurs with OpenCV 2.4.9, 2.4.10 and 2.3.0-beta.
  • To fix this issue, edit %VISP_WS%\opencv-2.y.z\sources\cmake\OpenCVConfig.cmake, and line 89 replace:
    if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
    by:
    if(OPENCV_GCC_TARGET_MACHINE MATCHES "64")
  • Then open a new cmd Command Prompt to build and install OpenCV again:
    C:\> cd %VISP_WS%\opencv-2.y.z\sources\build-mingw
    C:\> mingw32-make install

windres.exe invalid option --W

Note
This issue occurs with OpenCV 3.3.0.

When running mingw32-make if you get the following issue:

img-win10-mingw-opencv-issue-precompiled-headers.png

the workarround consists in:

  • opening cmake-gui and turning ENABLE_PRECOMPILED_HEADERS cmake var OFF:
    img-cmake-win10-mingw-opencv-issue-precompiled-headers.png
  • in cmake-gui press "Configure" button, then press "Generate" button
  • then in the cmd Command Prompt run again mingw32-make

Build error in cap_dshow.cpp

Note
This issue occurs with OpenCV 3.3.0.

When running mingw32-make if you get the following issue:

img-win10-mingw-opencv-issue-cap-dshow.png

the workarround consists in:

  • editing %VISP_WS%/opencv-3.3.0/sources/modules/videoio/src/cap_dshow.cpp adding
    #define NO_DSHOW_STRSAFE
    before the line
    #include "DShow.h"
  • then in the cmd Command Prompt run again mingw32-make

Next tutorial

You are now ready to see the next Tutorial: How to create and build a CMake project that uses ViSP on Unix or Windows that will show you how to use ViSP as a 3rd party to build your own project.