- Overview
- Video
- Steps
- 1.3.1. Find MSYS2
- 1.3.2. Download MSYS2
- 1.3.3. Install MSYS2
- 1.3.4. Update MSYS2 core packages
- 1.3.5. Update MSYS2 system packages
- 1.3.6. Find MinGW-w64 CMake
- 1.3.7. Install build tools
- 1.3.8. Find OpenSceneGraph repository
- 1.3.9. Install git to get OpenSceneGraph
- 1.3.10. Get latest OpenSceneGraph
- 1.3.11. Create build directory
- 1.3.12. Try to configure OpenSceneGraph with CMake
- 1.3.13. Add MinGW-w64 bin directory to PATH
- 1.3.14. Try to configure OpenSceneGraph once again
- 1.3.15. Observe configuration errors
- 1.3.16. Try to configure OpenSceneGraph for MinGW
- 1.3.17. Observe generator error
- 1.3.18. Clean build directory
- 1.3.19. Try to configure OpenSceneGraph for MinGW once again
- 1.3.20. Observe sh error
- 1.3.21. Update CMake MinGW script
- 1.3.22. Configure OpenSceneGraph
- 1.3.23. Build OpenSceneGraph
- 1.3.24. Try to install OpenSceneGraph
- 1.3.25. Observe installation error
- 1.3.26. Install OpenSceneGraph
- 1.3.27. Try to run 'osgviewer'
- 1.3.28. Observe missing library
- 1.3.29. Find MinGW libraries
- 1.3.30. Copy MinGW libraries
- 1.3.31. Go to the directory with 'osgviewer'
- 1.3.32. Check 'box.osgt' with 'osgviewer'
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.
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.
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.
Choose package suitable for your version of Windows. In case of 64-bit Windows, it's MSYS2 x86_64.
Run the downloaded package.
Run the following command in MSYS2:
pacman -Syu
Once finished, close MSYS2.
Reopen MSYS2 and run the following command:
pacman -Su
Now, MSYS2 is ready for us.
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
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.
Find OpenSceneGraph repository at the website.
Since OpenSceneGraph is hosted at GitHub, we need to install git.
To install git, run the following command:
pacman -S git
Get the latest copy of OpenSceneGraph with the following command:
git clone https://github.com/openscenegraph/OpenSceneGraph.git
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.
Before we can build OpenSceneGraph, we need to configure the build.
However, CMake is not yet reachable.
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.
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.
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.
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
CMake complains about using a generator that is different from the one used before.
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.
Configure OpenSceneGraph for MinGW once again.
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.
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.
Configure OpenSceneGraph once again. There are no more errors.
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.
Try to install with the following commands:
cd /path/to/build/dir
mingw32-make install
Installation failed, because MSYS2 needs administrative privileges to
install OpenSceneGraph into C:\Program Files (x86)
.
Restart MSYS2 with administrative privilegies and run the following commands:
cd /path/to/build/dir
mingw32-make install
Go to C:\Program Files (x86)\OpenSceneGraph
, which contains OpenSceneGraph
installation.
Try to run 'osgviewer' from bin
subdirectory.
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.
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.
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.
With MSYS2, go to C:\Program Files (x86)\OpenSceneGraph\bin
, where
osgviewer
resides.
Finally, take a look at the cube with osgviewer
:
./osgviewer /path/to/box.osgt