From MerlinWiki
Jump to: navigation, search

OpenSceneGraph page collects available information about Open Scene Graph related stuff. Feel free to contribute to it.


OSG (Open Scene Graph) is an open source high performance 3D graphics toolkit, used by application developers in fields such as visual simulation, games, virtual reality, scientific visualization and modelling. Written entirely in Standard C++ and OpenGL it runs on all Windows platforms, OSX, GNU/Linux, IRIX, Solaris, HP-Ux, AIX and FreeBSD operating systems. The OpenSceneGraph is now well established as the world leading scene graph technology, used widely in the vis-sim, space, scientific, oil-gas, games and virtual reality industries. You can find additional informations about OpenSceneGraph on site Introduction to OpenSceneGraph.

How to compile

We will see how to compile a default build of OSG with MS Visual Studio 9 2008 under windows, since this is the only way I did. Although it should be pretty same for other platform.

What do we need:

More about dependencies can be found here More about plugins
NOTE: With Visual Studio 10 2010 you need respective version of 3rd party libs:

We will build directly from trunk, which can be downloaded via svn from here If you don't know how to use svn, read SVN tutoriál. We will checkout into a directory named F:/OSG_trunk for this example. It may take a while so let's create another directory F:/OSG_build. Now as you can see we will do something called out of source build. It means that the product of this build will be in different directory than source. We also need the 3rd Party libs as stated before. We will unpack them to F:/OSG_trunk. The directory structure, if not now, should be apparent later. When we have this done and the checkout is complete, we can open the Cmake GUI. Now for the following picture:


This is what we should see.

  1. The path to our OSG trunk source code (The one which we just downloaded)
  2. The path where we want our OSG libs etc. to be stored
  3. And finaly click Configure button

Now we should see a little dialog beging us for selecting our, let's say, platform. We choos M$ VS 9 2008 but there are others hidden in the listbox. We also let it use native compilers, since we really plan to compile it in VS. And press Finish.


After some crunching and if we did all well till now, there will be some new items in the main window. Let's see:


If there is some error or something goes wrong you should check if your VS is properly installed, you haven't misstyped something etc. All lines are red. It's ok because Cmake didn't find some dependencies.

  • Firstly, in upmost red line: ACTUAL_3DPARTY_DIR - there we should give the actual 3rd party dir. I have mine here F:/OSG_trunk/3rdParty_x86_x64/x86. In this directory are ./bin and stuff like this. So change the path in Cmake.
  • Now we scroll down till COLLADA_DOM_ROOT and change it to F:/OSG_trunk/3rdParty_x86_x64/x86/include/1.4/dom.

That should be it for default build. If you're trying to compile some plugins as well there may be few more changes. Also there are some checkboxes which let you do some more customizing. Anyway it's up to your research. When we're done we click Configure again. There are some red lines with paths at the begining and the rest should be already white. When we check those red lines, we should see that they are pointing into correct and existing libs and maybe that GDAL was not found. I suppose that it's ok so just press Configure once more.


This picture is maybe an overkill but just to be sure. All should be white now and plenty of it wasn't found (like XUL, GDAL, DCMTK etc.), we really don't need them. So now guess what? We click Configure again and if we didn't do any changes the Generate button should be clickable now. Let's give it a try. Nothing special should've happened. After a few secs we can see generating done.
In F:\OSG_build we can now see the VS solution files.


Only thing to do now is to compile what we want. Open the OpenSceneGraph.sln, e.g. by double clicking on it.


Now on the left side we can see numerous projects but it's no interest of ours. Just select build configuration which suits you. I recommend both Release and Debug. It will build both release/debug versions of libraries respectively. Then pray, make necesary sacrifices to the Dark gods, dance Hula Hop and spill maple syrup all over your body. Then simply pres Build>Build Solution from the menu and humbly wait. I haven't encountered any inconveniencies, you might. Just figure it out.

Now we have our libs and dlls in F:/OSG_build/ - lib/ or bin/. Now it's up to you whether you want all your header files and libraries in one place or keep your OSG source (with headers) separate. I recomend to keep it all separately, because then you can keep only one copy of all. What I'm trying to say: If you copy header files from trunk directory to respective subdir in build, then you have two copies. It can lead into a situation when you edit or add some classes and rebuild, but forget to copy the headers again. When tou have them separately you just have to set different include and linker directories. Another little think to do is to copy Config file from F:\OSG_build\include\OpenThreads and F:\OSG_build\include\osg to its respective directories in F:\OSG_trunk.

Now this should be it. All you have to do now is set your project/compiler settings properly.

Other OSG related pages on this wiki

OSG knowledge base
Introduction to OpenSceneGraph

Favorite links

OSG Homepage:
Joseph Sullivan tutorial:
About referenced pointers:

Historical links

OSG doc (in compiled html):
OSGDirector: Project pages, Win32 binaries:
OSGEdit:, Win32 binaries: