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.1.2 and Mingw-w64 - GCC for Windows 64 & 32 bits.
- Note
- Concerning ViSP installation, we provide also other Tutorials.
Required packages
Mingw-w64
Mingw-w64 could be found following http://mingw-w64.sourceforge.net. From that page, click on download "Win-builds" that will bring you to the page http://win-builds.org/download.html 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:
- 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:\Users\...> setx MINGW_DIR "C:\mingw"
- Click on "OK" button. It will open an other window:
- 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 (in our case 92/92 packages, see next image) 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:\Users\...> echo %PATH%
C:\Users\...> setx PATH "%PATH%;C:\mingw\bin"
- Close and re-open a cmd terminal, then run again
C:\Users\...> echo %PATH%
to check that C:\mingw\bin was added.
CMake
CMake 2.8 or higher that could be download at : http://www.cmake.org In our case we install CMake 3.1.2.
- Download the latest binary distribution installer for Windows from http://www.cmake.org/download. You will find it under "Windows (Win32 Installer)".
- Install CMake just by double click on the binary cmake-3.1.2-win32-x86.exe you downloaded.
Getting ViSP source code
There are different ways to get ViSP source code.
Getting the latest release
You can download the latest stable release as a zip.
Getting the latest snapshot
When significant changes or bug fixes were introduced in the current developpement version of the source code, we provide snapshots.
If available, you can download a recent snapshot following the link.
Getting the source from Subversion
You can also get the cutting-edge ViSP version from Subversion repository svn://scm.gforge.inria.fr/svn/visp/trunk/ViSP.
One way to do that under Windows is to install Subversion that comes with Cygwin installer that is available on https://cygwin.com/install.html
- From the previous link, download Cygwin installer for 32-bits or 64-bits version.
- Double click on the setup binary to start installation. Keep the default settings and select a mirror.
- As shown in the next image, in the window that allows to select the packages, search for "subversion" and select "subversion" package in "Devel":
- Click on Next button twice to start installation, and then on Finish button to exit installer.
- Now you should be able to use subversion
C:\Users\...> C:\cygwin64\bin\svn.exe --version
svn, version 1.7.14
Once installed, to get ViSP source code run:
C:\Users\...> cd C:\ViSP
C:\Users\...> C:\cygwin64\bin\svn.exe checkout svn:
Configuring ViSP from source
We suppose now that ViSP source is in a directory denoted <source_dir>, for example C:\ViSP\ViSP-2.10.0
The goal of the configuration step is now to use CMake to produce all the material requested to build ViSP with Mingw. This material will be located in <binary_dir>, for example C:\ViSP\ViSP-2.10.0-build
.
- Launch CMake (cmake-gui) and complete the <source_dir> and <binary_dir> locations as in the next image.
- Click then on "Configure" button.
- Click on "Yes" to create the
C:\ViSP\ViSP-2.10.0-build
folder.
- Select then "MinGW Makefiles" and click on "Finish" button.
- This will start CMake configuration. As shown in the next image, ffmpeg, gdi, libjpeg, libpng, pthread and libxml2 3rd party are detected.
- As given in the previous image, note also that the installation folder is set to
C:\ViSP\ViSP-2.10.0-build\install
. - Warning
- If you want to change the installation forder to
C:/Program
Files
(x86)/ViSP, make sure that you have administrator privileges to write in that folder.
- 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.
Optional 3rd party packages
ViSP is interfaced with some 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.
OpenCV 3rd party
- We recommend to install OpenCV. Since OpenCV is not package for Mingw, you have to install OpenCV from source. From http://opencv.org/downloads.html download the latest OpenCV for Windows version. In our case we install
OpenCV-2.4.10.exe
pre-build SDK in C:\OpenCV
. The installer opencv-2.4.10.exe copied all the prebuilt binaries, but also the source code in C:\OpenCV\opencv
. - Note
- You can also install OpenCV 3.0.0. The principle remains the same.
- Now we have to use CMake to configure OpenCV from source. As <source_dir> we will set
C:\OpenCV\opencv\sources
and as <binary_dir> we set C:\OpenCV\opencv\sources\build-mingw
.
- Click then on "Configure" button.
- Click on "Yes" to create the
C:\OpenCV\opencv\sources\build-mingw
.
- Select then "MinGW Makefiles" and click on "Finish" button.
- Note
- Here you should encounter a first issue OpenCV endianness failure during CMake configuration.
- Modify "CMAKE_INSTALL_PREFIX" to
C:\OpenCV\opencv\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.
- Click on "Generate" button to generate the Makefiles for Mingw.
- Open a cmd terminal, enter in the <binary_dir> folder and start mingw32-make
C:\Users\...> cd C:\OpenCV\opencv\sources\build-mingw
C:\OpenCV\opencv\sources\build-mingw> mingw32-make
- Note
- Here you may encounter an other issue OpenCV build error: cannot build with tiff support and maybe the following if you try to build with OpenCV 3.0.0: OpenCV link error: cannot find -lRunTmChk and OpenCV build error: cannot build with dshow support.
- To install OpenCV run:
C:\OpenCV\opencv\sources\build-mingw> mingw32-make install
- Now in order that ViSP detects OpenCV you have to set
OpenCV_DIR
environment variable. Start up cmd terminal and enter: setx OpenCV_DIR C:\OpenCV\opencv\build
- Here the directory is the one where you have installed OpenCV. Inside this folder you should have a file named
OpenCVConfig.cmake
.
- Quit and restart CMake Gui on ViSP. It is important to quit CMake in order to take into account the new
OpenCV_DIR
environment variable. Click "Configure" button. As shown in the next image, a new red line indicating that OpenCV is found should appear.
- Note
- If OpenCV is not detected, you may encounter the following issue OpenCV not detected with Mingw build.
- If you enable the advanced view, you can see that we will use OpenCV libraries located in
C:/OpenCV/opencv/build/x64/mingw/lib
folder.
- Press "Configure" button again.
Ending the configuration
- To finish the configuration, click on "Generate" button.
- Once the generation is done, in
C:/ViSP/ViSP-2
.10.0-build folder you have the Makefile file that will be used by Mingw to build the entire project.
Building ViSP from source
- To build ViSP, open a cmd terminal, change to C:\ViSP\ViSP-2.10.0-build folder and run mingw32-make:
C:\Users\...> cd C:\ViSP\ViSP-2.10.0-build
C:\ViSP\ViSP-2.10.0-build> mingw32-make
- Note
- To Fix warning "ignoring #pragma comment(lib,"uuid.lib")" during build just follow the link.
- Now to install ViSP, in the same cmd terminal run:
C:\ViSP\ViSP-2.10.0-build> mingw32-make install
- At the end, in
C:/ViSP/ViSP-2
.10.0-build/install/x64/mingw/bin folder you have ViSP DLL library in libvisp-2100.dll file. - Note
- When CMAKE_BUILD_TYPE is set to Debug, the library name is 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 library, open a cmd terminal and run:
C:\Users\...> echo %PATH%
C:\Users\...> setx PATH "%PATH%;C:\ViSP\ViSP-2.10.0-build\install\x64\mingw\bin"
Then to add the path to OpenCV 3rd party library, close and re-open a cmd-terminal and run:
C:\Users\...> echo %PATH%
C:\Users\...> setx PATH "%PATH%;C:\OpenCV\opencv\build\x64\mingw\bin"
Then close and re-open a cmd terminal to check if the PATH var was well positioned
C:\Users\...> echo %PATH%
Appendix
Installing testing data
Some ViSP examples and tests require data set (images, models). These data set is provided as a compressed zip files.
Using testing data
- 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:\ViSP
. setx VISP_INPUT_IMAGE_PATH C:\ViSP
- It is also possible to run the examples and tests without positioning
VISP_INPUT_IMAGE_PATH
by using command line option -i
<path
to
the
data
set>
. If you want to run <binary
dir>/example/device/display/Debug/displayGDI.exe, open a command window, enter in the right folder, and run: displayGDI.exe -i C:\ViSP
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.
Known issues
OpenCV endianness failure during CMake configuration
- Note
- This issue occurs with OpenCV 2.4.10 and 2.3.0-beta.
If you encounter the following issue during CMake configuration
Edit C:\OpenCV\opencv\sources\CMakeLists.txt file, and line 464 replace:
test_big_endian(WORDS_BIGENDIAN)
by:
OpenCV build error: cannot build with tiff support
- Note
- This issue occurs with OpenCV 2.4.10 and 2.3.0-beta.
If you encounter a build issue during libtiff build as given in the next image:
- 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
C:\OpenCV\opencv\sources\build-mingw> mingw32-make
OpenCV not detected with Mingw build
- Note
- This issue occurs with OpenCV 2.4.10 and 2.3.0-beta.
- To fix this issue, edit C:\OpenCV\opencv\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:\OpenCV\opencv\sources\build-mingw> mingw32-make install
OpenCV link error: cannot find -lRunTmChk
- Note
- This issue occurs with OpenCV 2.3.0-beta and with OpenCV master branch.
The following image shows the link issue that may appear when building OpenCV with mingw:
A work arround is to configure OpenCV without ipp support turning WITH_IPP=OFF and then trying to build again.
OpenCV build error: cannot build with dshow support
- Note
- This issue occurs with OpenCV 2.3.0-beta and with OpenCV master branch.
The following image shows the link issue that may appear when building OpenCV with mingw:
A work arround is to configure OpenCV without Direct Show support turning WITH_DSHOW=OFF and then trying to build again.
Fix warning "ignoring #pragma comment(lib,"uuid.lib")" during build
During the build of ViSP the following warning may occur:
C:/mingw/mingw/include/urlmon.h:301:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(lib,"uuid.lib")
^
To remove this warning, edit C:/mingw/mingw/include/urlmon.h and comment line 301: