Building Examples



Environment variables

Project generation using CMake GUI

Project generation using CMake in command line

Creating/Modifying project


All example projects files for Linux and OS X must be generated on the host computer by CMake. For MS Visual Studio the project files are delivered with the package.

CMake is used to control the software compilation process using simple platform and compiler-independent configuration files (see CMakelists.txt in each example directory).
Most rules for specific platforms and architecture are built-in in CMake modules, but all of them can be specifically configured depending on needs. All Open Inventor example-specific rules can be found in the installed CMake directory.

CMake generates native make Makefiles or Visual Studio solutions that can be used in the compiler environment of your choice.

For details information on CMake, please see the official CMake website.


The following packages must be installed before project files can be generated for the examples.

  • Open Inventor Toolkit
    Note: You must install the version that matches the Open Inventor Demos package you are using.
  • CMake (see System Requirements Overview for more details about CMake version).
    Download it for your specific platform on the CMake (main version 3 and at least 3.2.1 or higher)
  • Qt 4.6.3 (Optional)
    If you want Qt-based examples to be built, you must install the Qt package.
    Installers can be found on the official Qt website

    Recommended version is Qt 4.6.3 as this is the version we have tested and officially support, but newer 4.x.x versions should work as Qt claims binary compatibility with newer minor versions.

  • CUDA/OpenCL (Optional)
    If you want CUDA and/or OpenCL-based examples to be built, you must install the package for your specific GPU.
    Installers can be found on the official website of your GPU providers.

Environment variables

Before generating and building examples example projects, following environment variables must be properly set:

  • OIVHOME must be set to the Open Inventor home installation folder (e.g. C:\Open Inventor\9.4.0 C++ Visual2012 x64).
  • OIVARCH must be set to the Open Inventor version (e.g. arch-Linux-x86_64-gcc44-release, arch-Windows-x86_64-msvc11-Release and so on).
  • For Qt examples, QTDIR  must be set to Qt folder.
  • Update PATH with <QTDIR>/bin.

Note that OIVHOME and OIVARCH are added automatically by the installer for Windows version.

Project generation using CMake GUI

Below the steps to use CMake GUI tool provided by the CMake installer.

  • Setup the Open Inventor examples input directory "Where is the source code" (e.g. C:/Open Inventor/9.4.0 C++ Visual2012 x64/src).
  • Setup the output directory "Where to build the binaries" where all generated files will be stored (e.g. C:/OIVBuildXYZ change XYZ to the Open Inventor version).
  • Press the Configure button.
  • CMake allows you to select the compiler version project target among those installed on the machine (e.g.: Visual Studio 11 2012):
  • After this step, CMake has checked the compiler options and library dependencies on your host computer, and allows you to customize some values:

Most of the time no changes are required. However, if desired, you can change default compiler options, set different paths to third party libraries, or just check that everything has been found correctly using this GUI.

  • If an error occurs, you are warned about it so that you can fix it and press the Configure button again. Repeat as necessary until the "Configuring done" message appears and no longer errors are shown.
  • Press the Generate button, CMake will generate all Makefiles or Projects/Solutions for all examples in the selected output directory:
  • If you have CMake errors, please check that:
    • With Linux: it is important to have this CMAKE_BUILD_TYPE=Release for release version and CMAKE_BUILD_TYPE=Debug for debug version.
    • Verify paths to third party libraries, see page system requirement for details on specific Operating System.

Project generation using CMake in command line

In Linux or OS X you can use both comand line or cmake-gui application.

Below an example of the command line that should be used:

cmake -DCMAKE_BUILD_TYPE=Release <path to <OIVHOME>/src>

Below an example using Linux command line: 

  1. Set environment variable:

setenv OIVHOME <path to Open Inventor>

setenv OIVARCH arch-Linux-x86_64-gcc41-release

setenv PATH ${QTDIR}/bin:$PATH

  1. Create a new folder for binaries in which you will run the CMake command. This folder should not be inside of the <OIVHOME>/src folder, for instance <OIVHOME>/buildDemo_release


mkdir buildDemo_release

  1. cd <OIVHOME>/buildDemo_release
  1. cmake -DCMAKE_BUILD_TYPE=Release ${OIVHOME}/src

If you have cmake errors please refer to cmake-gui chapter.

  1. to build executable, run command make (make -k if you want to build demo ignoring errors)

Creating/Modifying project

  • To modify an existing project, edit the CMakeLists.txt file located in the source folder of the demos. 
    Do not edit the project files, Makefiles or Visual studio project files (.vcproj/.sln or .vcxproj/.sln) directly, as CMake manages dependencies and they are rebuilt automatically when CMakeLists.txt files are changed.