Getting started with OSG

For those who don’t have a clue what to do with the libs and how to compile a simple example, here is the solution for Windows:

What you need:

  • Download the precompiled Libs (Binaries) for Windows (Vista & XP) (sorry my link doesn’t work anymore. But you can download them from openscenegraph.org)
  • Visual C++ Express (Microsoft Freeware)

Now extract all Files from the Lib archive you just downloaded and copy the content of the folder OSG somewhere on your PC. For example to c:osg. After that you should have 4 directories on C:

  • c:/osg/OpenSceneGraph-2.8.0
  • c:/osg/OpenSceneGraph-3rdParty
  • c:/osg/OpenSceneGraph-Data
  • c:/osg/OpenSceneGraph-Shared

Now install Microsoft Visual C++ Express and create a new project. It is important that this project is a console-application and a empty project. (There is an option in the wizard) Now edit the project settings like described. IMPORTANT: Edit the settings for “Release” and not for “Debug” —- IF ther is no C/C++ Option in the settings: simply add an empty .cpp file to your project!

- C/C++ -> General -> Additional Include Directories ->
“C:/osg/OpenSceneGraph-2.8.0/include”;”C:osg/OpenSceneGraph-3rdParty/include” (copy the ” as well)

- Linker -> General -> Additional Library Directories ->
“C:/osg/OpenSceneGraph-2.8.0/lib”;”C:osg/OpenSceneGraph-3rdParty/lib”

- Linker -> Input -> Additional Dependencies ->
“osg.lib OpenThreads.lib osgAnimation.lib osgDB.lib osgFX.lib osgGA.lib osgIntrospection.lib osgManipulator.lib osgParticle.lib osgShadow.lib osgSim.lib osgTerrain.lib osgText.lib osgUtil.lib osgViewer.lib osgVolume.lib osgWidget.lib curllib.lib freetype237.lib glut32.lib libjpeg.lib liblua51.lib libpng13.lib libtiff.lib libungif.lib vrpn.lib zlib1.lib

Now you can build your project (F7) IMPORTANT: switch application mode from debug to release (in toolpanel above codeediting window) before building!

After everything compiled without errors you should find your .exe application somewhere in home/Documents/Visual Studio 2008/Projects/Projectname/Release (depends on XP or Vista). If you try to start it it will crash (osg55-osg.dll not found or something similar) To fix that copy all .dll files from c:/osg/OpenSceneGraph-2.8.0/bin into the directory where your build is. It should work then.

Or as an alternative:  Set a environment variable “PATH” with value “C:/osgOpenSceneGraph-2.8.0/bin”. Restart is required.

Good Chance!

About the Author

Studying MultimediaTechnology in Salzburg, Austria