Compile C++ projects with OpenSceneGraph

In this article I’ll show you how to compile an OpenSceneGraph (OSG) C++ project and open it with Qt creator under Ubuntu 13.10 or 13.04.

I’m going to assume that the OSG has been installed on a location known to your system. If you have problems installing the most stable release you can try the following three commands:

Make sure you have a recent version of cmake ( > 2.6)

First create an empty directory for the new OSG project, enter the directory and create an empty CMakeLists.txt file.

Copy the following lines into the empty file:

The only parameter that need to be changed for every project is the name_of_main_file.cpp, which should be given without the suffix *.cpp

Before running the cmake you need to create file name_of_main_file.cpp which can be empty.

You can run cmake from the command line but here I’ll do it from Qt creator.

From Qt creator choose File->Open File or Project

Go to the directory you just created and pick the CMakeLists.txt file

Selection_020

 

This will launch the cmake wizard. In the first step you define the build location. By default this directory is different than the one created above. It is ok to use the same directory if you don’t build the project for different configurations.

Click Next and on the next step click Run CMake to configure the project.

Selection_022

 

Now you can start editing the name_of_main_file.cpp to create you OSG scene.

Qt creator should be able to provide autocompletion and suggestions for all the OSG classes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.