Skip to content

Building OpenSceneGraph on Ubuntu

Ravi Mathur edited this page Apr 2, 2020 · 22 revisions

Dependencies

The following dependencies are needed to build OpenSceneGraph and its associated plugins

Development

  • sudo apt install build-essential

Git

  • sudo apt install git

CMake

  • sudo apt install cmake
  • sudo apt install cmake-qt-gui (for cmake-gui, an easy-to-use cmake GUI)
    • Alternatively, sudo apt install cmake-curses-gui (for ccmake, a text-based cmake UI)

OpenGL

  • sudo apt install mesa-common-dev
  • sudo apt install freeglut3-dev

Font and Image loading

  • sudo apt install libfreetype6-dev fonts-liberation
  • sudo apt install libpng-dev libjpeg-dev libtiff-dev

(Optional) Qt

  • download .run installer
  • chmod +x *.run in the Terminal
  • ./<RUNFILE>.run
  • follow on-screen instructions to install
  • Qt install path with be referred to as [QT_ROOT] by this wiki

Download OpenSceneGraph

  • git clone https://github.com/openscenegraph/OpenSceneGraph.git --branch OpenSceneGraph-X.X.X where X.X.X is replaced by the latest stable tag under Branch > Tags on Github
  • the root OpenSceneGraph directory will be referred to as [OSG_ROOT] by this wiki

Setup OpenSceneGraph Build System

In Terminal:

  1. cd [OSG_FOLDER]
  2. mkdir build
  3. mkdir install
  4. cd build
  5. cmake ..
  6. cmake-gui (alternatively ccmake .)
    • Enable "Grouped" and "Advanced" options
    • Set CMAKE_INSTALL_PREFIX = [OSG_FOLDER]/install
    • (Optional) BUILD_OSG_EXAMPLES = ON
    • Ensure that OPENGL_INCLUDE_DIR, OPENGL_gl_LIBRARY, and OPENGL_glu_LIBRARY were found
    • Configure, then Generate

Build OpenSceneGraph

In Terminal:

  1. cd [OSG_FOLDER]/build if you aren't already there
  2. make or make -j <NUMBER_OF_CORES> if you know the number of cores your computer has
  3. sudo make install to install the compiled OpenSceneGraph into the [OSG_FOLDER]/install folder
  4. Confirm that the osgversion executable is in [OSG_FOLDER]/install/bin

Test OpenSceneGraph

In Terminal:

  1. Add the following to your .bashrc login file
export OSG_ROOT=[OSG_FOLDER]/install
export PATH=$PATH:$OSG_ROOT/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OSG_ROOT/lib
  1. source ~/.bashrc
  2. Run osgversion in the Terminal, it should tell you the version of OpenSceneGraph that you have installed

Congratulations, OpenSceneGraph is now built and installed; ready for use with OpenFrames!

Further Testing

  • Download the resources from here
  • Unzip the files
  • cd to the unzipped directory
  • osgviewer cow.osg --window 0 0 640 480 to run a demo visualization of a cow