Visual Servoing Platform  version 3.0.0
Tutorial: Installation from source on Windows 8.1 with Visual C++ 2013

In this tutorial you will learn how to install ViSP from source on Windows 8.1 with Visual C++. These steps have been tested on Windows 8.1 (64 bit), with CMake 3.3.2 and Visual Studio Express 2013 but should work with any other version as well.

Note
Concerning ViSP installation, we provide also other Tutorials.

Install prerequisities

  • Visual Studio C++. Note that ViSP can also be build with Visual Studio Express that could be downloaded from http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products . In this tutorial we use Visual Studio Express 2013.
    Note
    If you want to use Visual Studio Express, you have to install Express 2013 for Windows Desktop. The Desktop version is important to work with CMake.
  • CMake 2.8.3 or higher that could be download at : http://www.cmake.org. To install CMake, download the latest binary distribution installer for Windows. You will find it under "Windows (Win32 Installer)". Install CMake just by double clicking on the binary cmake-x.y.z-win32-x86.exe you downloaded.

Install 3rd parties

ViSP is interfaced with several 3rd party libraries. The complete list is provided here.

Recommended 3rd parties

We recommend to install the following:

Windows SDK 3rd party

We recommend to install the "Windows Software Development Kit (SDK) for windows 8.1" to get the Graphical Device Interface (GDI) capabilities. The GDI is used in ViSP to display images in a window thanks to vpDisplayGDI class.

OpenCV 3rd party

We recommend also to install OpenCV.

  • From http://opencv.org/downloads.html download the latest OpenCV for Windows version. In our case we install opencv-3.0.0.exe pre-build SDK in C:\OpenCV. The installer opencv-3.0.0.exe extracted all the material in C:\OpenCV\opencv.
    Note
    OpenCV 3.0.0 windows installer contains pre-build libraries compatible with Visual C++ 2013 (in C:\OpenCV\opencv\build\x86\vc12 and in C:\OpenCV\opencv\build\x64\vc12 for the Win64 compiler) and also libraries compatible with Visual C++ 2012 (in C:\OpenCV\opencv\build\x86\vc11 and in C:\OpenCV\opencv\build\x64\vc11 for the Win64 compiler). With any other compiler version you need to build yourself OpenCV from source.
    There is an OpenCV tutorial: Installation Using the Pre-build Libraries that may help if you encounter some difficulties.
  • Now in order that ViSP detects OpenCV you have to set OpenCV_DIR environment variable. Start up a command window (in your "Start" menu click on "Run" and type in cmd.exe) and enter:
    setx OpenCV_DIR C:\OpenCV\opencv\build
    where C:\OpenCV\opencv\build is where you have the build directory (extracted or built). 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.

Other optional 3rd parties

We give also the way to install other 3rd party libraries to enable specific capabilities.

Ogre3D 3rd party

Warning
Ogre3D installation from source code described in this section is reserved to expert users.

If you are interested in augmented reality (see vpAROgre), or if you want to enable advanced visibility computation during model-based tracking (see vpMbTracker::setOgreVisibilityTest() and Tutorial: Markerless model-based tracking) we recommend to install Ogre3D. You can check if a prebuild SDK matches your Visual C++ version, and follow the SDK installation instructions. You can also install the lastest release from source. Based on our experience, this is what we recommend.

Ogre source code is hosted on BitBucket. On Ogre wiki you will find useful information to build and install Ogre from source. Hereafter we give the main steps.

Ogre prerequisities

  • To build Ogre on Windows you will need to install the DirectX SDK. Since Windows 8, DirectX is no longer a standalone package, rather it is bundled in the Windows 8.x SDK. The latest version is the Windows 8.1 SDK.
  • To get the Ogre source code but also the source code of all the dependencies hosted on BitBucket and available with Mercurial, you have to install TortoiseHg.

Getting Ogre dependencies

  • A repository containing Ogre dependencies source code is available here at BitBucket.
  • Open an explorer window, and enter in TortoiseHg Clone menu. Select as source https://bitbucket.org/cabalistic/ogredeps and as destination C:\Ogre\ogredeps as in the next image:
    img-win8.1-ogredeps-tortoisehg.jpg
  • Click on Clone button to get dependencies source code in C:\Ogre\ogredeps

Building Ogre dependencies

  • To build the dependencies, open CMake GUI and set source code location pointing to C:\Ogre\ogredeps and build location pointing to C:\Ogre\ogredeps\build. Select Visual Studio 12 2013 Win64 as generator, click on "Configure" button twice and then on "Generate" button. You should have something similar to the next image:
    img-win8.1-cmake-ogredeps.jpg
  • Open C:\Ogre\ogredeps\build\OGREDEPS.sln solution file with Visual C++.
  • In Visual, select Debug configuration and build INSTALL project:
    img-win8.1-msvc-build-ogredeps.jpg
    Note
    If the build fails due to the environment variable DXSDK_DIR that is not set, see Unable to build ogredeps: DXSDK_DIR missing for a work arround.
  • In Visual, select also Release configuration and build again INSTALL project.
  • Now in C:\Ogre\ogredeps\build\ogredeps\bin you will find the Cg and OIS dependencies build in Debug and Release:
    img-win8.1-ogredeps-explorer.jpg
  • To finish dependencies installation, set OGRE_DEPENDENCIES_DIR environment variable pointing to C:\Ogre\ogredeps\build\ogredeps
    setx OGRE_DEPENDENCIES_DIR C:\Ogre\ogredeps\build\ogredeps

Getting Ogre source

  • From Ogre download page, identify the last release. In our case Ogre 1.9 that is on BitBucket repository under branch v1-9.
  • Open an explorer window, and enter in TortoiseHg Clone menu. Select as source https://bitbucket.org/sinbad/ogre, as destination C:\Ogre\ogre and select revision v1-9 corresponding to the branch of the latest release as presented in the next image:
    img-win8.1-ogre-tortoisehg.jpg
  • Click on Clone button to get Ogre source code in C:\Ogre\ogre

Building Ogre source

  • Close and re-open CMake Gui. Set source code location pointing to C:\Ogre\ogre and build location pointing to C:\Ogre\ogre\build. Select Visual Studio 12 2013 Win64 as generator, click on "Configure" button and then on "Generate" button. You should have something similar to the next image:
    img-win8.1-cmake-ogre.jpg
    Note
    As shown in the previous image, Ogre installation folder is set to C:\Ogre\ogre\build\sdk.
  • Open C:\Ogre\ogre\build\OGRE.sln solution file with Visual C++.
  • In Visual, select Debug configuration and build INSTALL project.
  • In Visual, select also Release configuration and build again INSTALL project.
  • Now in C:\Ogre\ogre\build\sdk\bin you will find all the libraries in Debug and Release configuration, including Cg and OIS dependencies there where build previously.
    img-win8.1-ogre-explorer.jpg
  • To finish Ogre installation set OGRE_HOME environment variables to C:\Ogre\ogre\build\sdk location.
    setx OGRE_HOME C:\Ogre\ogre\build\sdk

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 using for example WinRAR
  • You can also download a daily snapshot. Once visp-snapshot-yyyy-mm-dd.tar.gz is downloaded, uncompress the file using for example WinRAR
  • Or you get the cutting-edge ViSP from GitHub repository using the git command line (see How to install Git):
    C:\ViSP> git clone https://github.com/lagadic/visp.git

We suppose now that ViSP source is in a directory denoted <source_dir>, for example C:\ViSP\visp

Configuring ViSP from source

The goal of the configuration step is now to use CMake to produce a Visual Studio C++ solution that will be located in <binary_dir>, for example C:\ViSP\visp-build.

  • Launch CMake (cmake-gui) and complete the <source_dir> and <binary_dir> locations as in the next image.
img-cmake-win8.1-msvc-launch.jpg
  • Click then on "Configure" button.
img-cmake-win8.1-create-build-folder.jpg
  • Click on "Yes" to create the C:\ViSP\visp-build folder.
  • Select then your compiler, for example here Visual Studio Express 2013 Win64, and click on "Finish" button.
img-cmake-win8.1-msvc-version.jpg
  • This will start CMake configuration. As shown in the next image, GDI (Graphical Device Interface), OpenCV, Ogre and OpenMP 3rd parties are automatically detected.
img-cmake-win8.1-config.jpg
  • As given in the previous image, note also that the installation folder is set to C:\ViSP\visp-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.
    img-cmake-win8.1-config-end.jpg
    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-win8.1-msvc-generate.jpg
  • Once the generation is done, in C:/ViSP/visp-build folder you have the Visual Studio VISP.sln generated solution file.
img-win8.1-msvc-solution.jpg

Building ViSP from source

  • To build ViSP just double click on C:/ViSP/visp-build/VISP.sln solution file. This action will open ViSP project in Visual Studio C++. As shown in the next image, by default, Visual Studio position the solution configuration to Debug.
img-win8.1-msvc-open.jpg
  • Enter menu "BUILD/Build Solution" to build ViSP.
img-win8.1-msvc-build.jpg
  • At the end of the build process you should have the following indicating that all the build succeeded.
img-win8.1-msvc-build-end.jpg
  • Now to install ViSP, build "INSTALL" project. To this end, apply a left click on "INSTALL" to select the project, then a right click to enter in the "Build" menu.
img-win8.1-msvc-install.jpg
  • At the end of the installation, you should have the following.
img-win8.1-msvc-install-end.jpg
  • As shown in the previous image, all the headers but also the generated library are copied in C:/ViSP/visp-build/install folder.
  • This ends ViSP installation with Debug configuration.
  • We recommend now to do the same with Release settings. As shown in the next image, select the Release configuration.
img-win8.1-msvc-release.jpg
  • Now, as previously, build and install ViSP again.
  • At the end, in C:/ViSP/visp-build/install/x64/vc12/bin folder you have two versions of ViSP DLL libraries corresponding to ViSP modules; the one suffixed by "d" with debug information, the other one optimized with release compiler options.
img-win8.1-explorer-install-end.jpg

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:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\ViSP\visp-build\install\x64\vc12\bin"

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

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\OpenCV\opencv\build\x64\vc12\bin"

If installed, you have also to add the location of Ogre 3rd party libraries to the path. Close and re-open a cmd terminal to run:

C:\> echo %PATH%
C:\> setx PATH "%PATH%;C:\Ogre\ogre\build\sdk\bin\release"
C:\> setx PATH "%PATH%;C:\Ogre\ogre\build\sdk\bin\debug"

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-x.y.z.zip from http://visp.inria.fr/download and uncompress it for example in C:/ViSP.

img-win8.1-visp-images.jpg

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
Note
For historical reasons VISP_INPUT_IMAGE_PATH should not contain the folder ViSP-images, but the parent folder.

From now, you can try to run ViSP examples and tests. For example, if you want to run <binary dir>/example/device/display/Debug/displayGDI.exe, open a command window, enter in the right folder, and run:

img-win8.1-cmd-displayGDI.jpg

Known issues

Unable to build ogredeps: DXSDK_DIR missing

During ogredeps build as described in Ogre3D 3rd party installation you may get in Visual C++ the following error when building SDL2 project:

error: DIRECTX requires $DXSDK_DIR environment variable to be set
img-win8.1-msvc-ogredeps-issue.jpg

To fix the issue:

  • Quit Visual C++ and start again CMake over ogredeps project
  • Disable SDL2 dependency build turning OGREDEPS_BUILD_SDL2 option off
    img-win8.1-cmake-ogredeps-issue.jpg
  • Configure and generate again the project
  • Open C:\Ogre\ogredeps\build\OGREDEPS.sln solution file with Visual C++ and try a new build as described in Ogre3D 3rd party

Model-based trackers are not working with Ogre visibility ckeck

If you run mbtEdgeTracking.exe, mbtKltTracking.exe or mbtEdgeKltTracking.exe enabling Ogre visibility check (using "-o" option), you may encounter the following issue:

C:\ViSP\visp-build\example\Tracking\Debug> mbtEdgeTracking.exe -c -o
...
OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource VTFInstancing.cg in resource group General
...
Initializing OIS ***

and then a wonderful runtime issue as in the next image:

img-win8.1-msvc-mbtracker-ogre-issue.jpg

It means maybe that Ogre version is not compatible with DirectX 11. This can be checked adding "-w" option to the command line:

C:\ViSP\visp-build\example\Tracking\Debug> mbtEdgeTracking.exe -c -o -w

Now the binary should open the Ogre configuration window where you have to select "OpenGL Rendering Subsystem" instead of "Direct3D11 Rendering Subsystem". Press then OK to continue and start the tracking of the cube.

img-win8.1-msvc-mbtracker-ogre-opengl.jpg

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.