- Overview
- Video
- Steps
- 1.2.1. Find OpenSceneGraph repository
- 1.2.2. Install git to get OpenSceneGraph
- 1.2.3. Get latest OpenSceneGraph
- 1.2.4. Create build directory
- 1.2.5. Try to configure OpenSceneGraph with CMake
- 1.2.6. Install CMake to configure OpenSceneGraph
- 1.2.7. Try to configure OpenSceneGraph once again
- 1.2.8. Observe configuration errors
- 1.2.9. Install missing OpenGL libraries
- 1.2.10. Configure OpenSceneGraph
- 1.2.11. Observe found OpenGL library location
- 1.2.12. Build OpenSceneGraph
- 1.2.13. Install OpenSceneGraph
- 1.2.14. Try to check 'box.osgt' with 'osgviewer'
- 1.2.15. Locate OpenSceneGraph libraries
- 1.2.16. Tell dynamic linker where to find OpenSceneGraph libraries
- 1.2.17. Check 'box.osgt' with 'osgviewer'
This tutorial is part of OpenSceneGraph cross-platform guide.
In this tutorial we install OpenSceneGraph under Linux 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 Xubuntu 16.04.
Note: steps below use frames from the video as screenshots. Watch the video to see all details.
Find OpenSceneGraph repository at the website.
Since OpenSceneGraph is hosted at GitHub, we need to install git.
To install git on Debian based distributions, run the following command:
sudo apt install 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 installed.
To install CMake on Debian based distributions, run the following command:
sudo apt install cmake
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 resolve OPENGL_INCLUDE_DIR
variable. This means CMake could not find OpenGL libraries.
The easiest way to install OpenGL libraries is to install GLUT development package, which will bring OpenGL libraries in as a dependency.
To install GLUT development package on Debian based distributions, run the following command:
sudo apt install freeglut3-dev
Configure OpenSceneGraph once again. There are no OpenGL errors anymore.
As you see, configuration process has successfully found OpenGL libraries.
We are finally ready to build OpenSceneGraph with the following command:
make -j10
We use -j10
to run 10 parallel jobs. This makes building faster.
Install OpenSceneGraph with the following command:
sudo make install
Try to take a look at the cube with osgviewer tool.
Turns out, it cannot find OpenSceneGraph libraries.
By default, OpenSceneGraph libraries are installed into /usr/local/lib64
on 64-bit Linux distributions. This location is not standard.
Specify /usr/local/lib64
inside /etc/ld.so.conf
to make sure
dynamic linker is aware of the directory with OpenSceneGraph libraries.
Then refresh the linker cache with the following command:
sudo ldconfig
Finally, take a look at the cube with osgviewer tool:
osgviewer /path/to/box.osgt