Visual Servoing Platform  version 3.1.0
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.10.0 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 terminal:
    C:\> setx MINGW_DIR "C:\folder\mingw-w64"
  • 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 a cmd terminal and do the following:
    C:\> echo %PATH%
    C:\> setx PATH "%PATH%;C:\mingw\bin"
  • Close and re-open a cmd terminal, then run again
    C:\> echo %PATH%
    to check that C:\mingw\bin was added.

CMake

CMake could be download at : 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.10.0-rc3-win64-x64.msi). To install just double click on the msi file.

Create a workspace

First create a workspace that will contain all ViSP and optional 3rd parties. This workspace is here set to C:\workspace folder, but it could be set to any other location. To create the workspace:

  • Open a cmd terminal (in your "Start" menu click on "Run" and type in cmd.exe) and run:
    C:\> mkdir C:\workspace

Install recommended 3rd parties

ViSP is interfaced with several 3rd party libraries. The complete list is provided here. Some of them are automatically detected since they are part of MinGW distribution. Other may be installed from source. We recommend to install the following:

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-3.3.0-vc14.exe Win pack installer.
  • Extract the content of the archive in C:\workspace.
    img-win10-extract-opencv.png
  • The installer extracted all the material in C:\workspace\opencv.
  • We strongly recommend to rename this folder to a name that contain OpenCV version like C:\workspace\opencv-3.3.0.

OpenCV 3.3.0 windows installer contains pre-build libraries compatible with Visual C++ 2015 (vc14) in C:\workspace\opencv-3.3.0\build\x64\vc14. Since here you are using MinGW you need to build yourself OpenCV from source and install the libraries in C:\workspace\opencv-3.3.0\build\x64\mingw.

2. Configure OpenCV

To build OpenCV from source with MinGW:

  • Launch CMake (cmake-gui), complete the source code and build locations as in the next image.
    img-cmake-win10-mingw-opencv-launch.png
  • Click then on "Configure" button.
  • Click on "Yes" to create C:\workspace\opencv-3.3.0\sources\build-mingw folder.
  • Select then "MinGW Makefiles" and click on "Finish" button.
  • Modify "CMAKE_INSTALL_PREFIX" to C:\workspace\opencv-3.3.0\build folder. This is the location of the pre-build libraries that come with the installer. Doing that, allows to install OpenCV libraries in a same parent folder.
    img-cmake-win10-mingw-opencv-install.png
  • Click then on "Configure" button to remove the red lines.
  • Click on "Generate" button to generate the Makefiles for MinGW.

3. Build OpenCV

4. 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 terminal and enter:
    C:\> setx OpenCV_DIR C:\workspace\opencv-3.3.0\build
    where C:\workspace\opencv-3.3.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 in the PATH environment variable following the indications mentioned in Setting up PATH variable.

Install ViSP from source code

Getting 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 C:\workspace\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 C:\workspace\visp\visp-x.y.z using for axample WinRAR.
  • Or you get the cutting-edge ViSP from GitHub repository using the git command line (see How to install Git):
    C:\> mkdir C:\workspace\visp
    C:\> cd C:\workspace\visp
    C:\> git clone https://github.com/lagadic/visp.git

We suppose now that ViSP source is in C:\workspace\visp\visp.

Configuring ViSP from source

The goal of the configuration step is now to use CMake to produce MinGW Makefiles in C:/workspace/visp/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 C:/workspace/visp/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 C:/workspace/visp/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.
    img-cmake-win10-mingw-visp-config2.png
    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 C:/workspace/visp/visp-build-mingw folder you have the Makefile file that will be used by MinGW to build the whole project.

Building ViSP from source

  • To build ViSP, open a cmd terminal, change to C:\workspace\visp\visp-build-mingw folder and run mingw32-make:
    C:\> cd C:\workspace\visp\visp-build-mingw
    C:\> mingw32-make -j4
  • Now to install ViSP, in the same cmd terminal run:
    C:\> mingw32-make -j4 install
  • At the end, in C:/workspace/visp/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".

Setting up PATH variable

If you built static libraries then you are done. Otherwise, if you follow this tutorial step by step you need to add the bin folders path to the systems path. This is because you will use ViSP and OpenCV libraries in form of "Dynamic-link libraries" (also known as DLL). Inside these are stored all the algorithms and information the libraries contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems PATH variable contains a list of folders where DLLs can be found. Add ViSP and OpenCV libraries path to this and the OS will know where to look if he ever needs the libraries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (exe) for the OS to find it.

To modify the PATH var and add the path to ViSP libraries, open a cmd terminal and run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\visp\visp-build-mingw\install\x64\mingw\bin"

Then to add the path to OpenCV 3rd party libraries, close and re-open a cmd-terminal and run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\workspace\opencv-3.3.0\build\x64\mingw\bin"

Then close and re-open a cmd terminal to check if the PATH var was well positioned

C:\> echo %PATH%

Install ViSP dataset

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.

Download visp-images-3.1.0.zip from http://visp.inria.fr/download and uncompress it in your workspace C:/workspace.

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 C:\workspace\visp-images-3.1.0.

C:\> setx VISP_INPUT_IMAGE_PATH C:\workspace\visp-images-3.1.0

From now, you can try to run ViSP examples and tests. For example, if you want to run C:/worspace/visp/visp-build-mingw/example/device/display/Debug/displayGDI.exe, open a command window, enter in the right folder, and run:

img-win10-mingw-cmd-displayGDI.png

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 C:\workspace\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 C:\workspace\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 C:\workspace\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 terminal to build and install OpenCV again:
    C:\> cd C:\workspace\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 terminal 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 C:/workspace/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 terminal 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.