Skip to content

Latest commit

 

History

History

1.3.InstallUnderWindows

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Table of contents

This tutorial is part of OpenSceneGraph cross-platform guide.

In this tutorial we install OpenSceneGraph under Windows and take a look at the cube with osgviewer tool.

Note: this tutorial requires OpenSceneGraph model created in 1.1. Create a cube.

YouTube | Download

Video depicts OpenSceneGraph installation under 64-bit Windows 7.

Note: steps below use frames from the video as screenshots. Watch the video to see all details.

Screenshot

MSYS2 is a software distro and building platform for Windows.

We use MSYS2 to build and install OpenSceneGraph, because it provides Unix-like environment with everything that is necessary to build Windows applications: Git, CMake, GCC and a lot more.

Screenshot

Choose package suitable for your version of Windows. In case of 64-bit Windows, it's MSYS2 x86_64.

Screenshot

Run the downloaded package.

Screenshot

Run the following command in MSYS2:

pacman -Syu

Once finished, close MSYS2.

Screenshot

Reopen MSYS2 and run the following command:

pacman -Su

Now, MSYS2 is ready for us.

Screenshot

In order to build Windows applications, we need to use MinGW-w64 tools. MinGW-w64 is an advancement of the original MinGW project, created to support the GCC compiler on Windows.

To find relevant CMake package, run the following command:

pacman -Ss mingw-w64 | grep cmake

Screenshot

To install CMake, Make, and GCC, run the following command:

pacman -S mingw-w64-i686-cmake mingw-w64-i686-make mingw-w64-i686-gcc

We use 32-bit versions, because we want to build 32-bit OpenSceneGraph, which would work on both 32- and 64-bit Windows.

Screenshot

Find OpenSceneGraph repository at the website.

Screenshot

Since OpenSceneGraph is hosted at GitHub, we need to install git.

To install git, run the following command:

pacman -S git

Screenshot

Get the latest copy of OpenSceneGraph with the following command:

git clone https://github.com/openscenegraph/OpenSceneGraph.git

Screenshot

OpenSceneGraph uses CMake build system, which supports out-of-source builds. We create a build directory to keep generated (built) content separate from the original source.

Screenshot

Before we can build OpenSceneGraph, we need to configure the build.

However, CMake is not yet reachable.

Screenshot

CMake is not yet reachable, because it's a MinGW package. MinGW packages reside in a non-standard path.

To make MinGW CMake (and other MinGW executables) accessible, we need to add MinGW bin directory to PATH environment variable. Do it by appending the following line:

export PATH=$PATH:/mingw32/bin

to ~/.bashrc file.

Restart MSYS2 for the changes to take effect.

Screenshot

Try to configure OpenSceneGraph build with the following commands:

cd /path/to/build/dir

cmake /path/to/source/dir

We use default configuration without specifying anything.

Screenshot

As you see, configuration process could not find valid compiler for NMake Makefiles. That's because NMake Makefiles are for Visual Studio, but we use MinGW's GCC.

Screenshot

Since we want to use MinGW's GCC, we need to tell CMake to generate MinGW Makefiles. We do it by adding -G "MinGW Makefiles" to the configuration command:

cmake -G "MinGW Makefiles" ~/p/OpenSceneGraph

Screenshot

CMake complains about using a generator that is different from the one used before.

Screenshot

To fix generator error, we need to clean build directory with the following commands:

cd /path/to/build/dir

rm -R *

Warning: make sure you run rm command from the build directory only! This command removes all files in the current directory and descendant ones.

Screenshot

Configure OpenSceneGraph for MinGW once again.

Screenshot

CMake complains about sh.exe presence in PATH. As we seen before, MinGW resides in a non-standard path to make sure MinGW executables do not conflict with Cygwin executables.

Since MSYS2 uses Cygwin underneath, CMake detected MinGW and Cygwin mix.

Screenshot

Since we only installed MinGW build tools, we can remove sh.exe check by commenting out relevant lines in /mingw32/share/cmake-*/Modules/CMakeMinGWFindMake.cmake file.

Screenshot

Configure OpenSceneGraph once again. There are no more errors.

Screenshot

We are finally ready to build OpenSceneGraph with the following command:

mingw32-make -j10

We use -j10 to run 10 parallel jobs. This makes building faster.

Screenshot

Try to install with the following commands:

cd /path/to/build/dir

mingw32-make install

Screenshot

Installation failed, because MSYS2 needs administrative privileges to install OpenSceneGraph into C:\Program Files (x86).

Screenshot

Restart MSYS2 with administrative privilegies and run the following commands:

cd /path/to/build/dir

mingw32-make install

Screenshot

Go to C:\Program Files (x86)\OpenSceneGraph, which contains OpenSceneGraph installation.

Try to run 'osgviewer' from bin subdirectory.

Screenshot

You cannot run 'osgviewer' at this time, because it misses several libraries.

Those libraries are part of MinGW installation. However, since they reside in non-standard place, 'osgviewer' executable can't find them.

Screenshot

The easiest way to locate MinGW installation directory, is to run the following command from within MSYS2:

explorer .

This will open your current directory in Explorer.

From there, you can navigate to mingw32/bin directory. This is the place where MinGW libraries reside.

Screenshot

Copy all files with dll extension to the directory, where osgviewer resides.

Note: you don't really need all MinGW libraries. We copy all libraries just to keep this tutorial simpler.

Screenshot

With MSYS2, go to C:\Program Files (x86)\OpenSceneGraph\bin, where osgviewer resides.

Screenshot

Finally, take a look at the cube with osgviewer:

./osgviewer /path/to/box.osgt