After much work and a lot of wrong turns, I’ve finally gotten help with installing OpenSceneGraph on Windows XP. It was simple after all, at least using the pre-compiled binaries. There are up to date tutorials for how to install from source after all, but that wasn’t my goal. I just wanted to get started making apps using OSG. With some helpful advice from the OSG community, here’s my detailed instructions for installing OSG on Windows XP from the pre-compiled binaries for use with Visual Studio 2005. The instructions are similar for other versions of Windows and Visual Studio, but I have no experience with them with regard to OSG. This tutorial assumes some experience (but not much) with C++, Visual Studio, command line usage, and Windows XP.
- First, you have to actually get the binaries. They can be found here.
- Download the packages labeled openscenegraph-all-2.8.0-win32-x86-vc80sp1-Debug.tar.gz and openscenegraph-all-2.8.0-win32-x86-vc80sp1-Release.tar.gz. They are the files associated with the Debug and Release builds, respectively.
- Also download the Sample Datasets (found here).
- Uncompress all three archives (try 7-zip for the .tar.gz files). Put all the directories from the Debug release in a directory you want to be the install directory. I’m going to assume C:\Program Files\OpenSceneGraph-2.8.0 from now on as the root for your installation.
- Inside the root, you should now see that it contains the folders: bin, doc, include, lib, and share
- So you can use both the debug and release builds of each library, go to the Release version’s folder (uncompressed) and copy all the contents into your installation directory. If and when it asks to overwrite a file, click no to all.
- It doesn’t really matter where you put the Sample files, so I made a folder in my installation directory called “samples” and copied them there (specifically “C:\Program Files\OpenSceneGraph-2.8.0\samples\OpenSceneGraph-Data-2.8.0″). These files are useful for running examples and giving access to basic fonts and textures.
- Now the files are “installed”, but Windows doesn’t know how to use them. To do that, we have to modify the environmental variables.
- Right-click on My Computer and select Properties.
- Select the Advanced tab.
- Click the Environmental Variables button.
- Under “System Variables” select the New button.
- Give the variable name “OSG_ROOT”.
- Give the variable value “C:\Program Files\OpenSceneGraph-2.8.0″ or whereever your install directory is.
- Now do the same for several other references, which refer to the OSG_ROOT variable:
- Name: OSG_BIN_PATH | Value: %OSG_ROOT%\bin
- Name: OSG_INCLUDE_PATH | Value: %OSG_ROOT%\include
- Name: OSG_LIB_PATH | Value: %OSG_ROOT%\lib
- Name: OSG_SAMPLES_PATH | Value: %OSG_ROOT%\share\OpenSceneGraph\bin
- Name: OSG_FILE_PATH | Value: %OSG_ROOT%\samples\OpenSceneGraph-Data-2.8.0 (note: your directory structure may be different, see above)
- Then, select the already existing Path variable, and click Edit.
- To the end of the line, after the final semi-colon, add “%OSG_BIN_PATH%;%OSG_SAMPLES_PATH%;”
- Apply your changes and close the windows
- Your environmental variables should be successfully changed.
- To make sure they are working, open a command line window by going to Start, then Run, type “cmd”, and push OK.
- Type in “echo %OSG_ROOT%” and hit enter. It should display your install directory.
- At this point, you can also test to make sure Windows understands where OSG is. Open a command line window and type “osgversion”. It should return the version of OSG, namely “OpenSceneGraph Library 2.8.0″.
- Furthermore, you can test that the sample datasets have been installed by typing “osgviewer cow.osg” into the command line window. This should open the cow model in OSG’s viewer program. Push the escape key to exit.
- Now, we need to set up Visual Studio.
- Open Visual Studio 2005. If it was already open, close it and reopen it (so that it will get the latest changes you just made above).
- Select File > New > Project… and choose Empty Project under Visual C++ > General.
- Put it in a directory you’ll remember, and name is something like “OSGDefaultProject”.
- So that you will have all the necessary available options, create a new C++ file that will serve as your main file. (I named mine “Main.cpp”.)
- Select Project > [ProjectName] Properties…
- Select the Debug option from the Configuration dropdown.
- Select Configuration Properties > C/C++ > General
- Select the box to the right of Additional Include Directories and paste “$(OSG_INCLUDE_PATH)” there.
- Select Configuration Properties > C/C++ > Preprocessor
- Select the box to the right of Preprocessor Definitions and paste “WIN32;_WIN32;_DEBUG”
- Select Configuration Properties > Linker > General
- Select the box to the right of Additional Library Directories and paste “$(OSG_LIB_PATH)”
- Select Configuration Properties > Linker > Input
- Select the box to the right of Additional Dependencies and paste whatever libraries you will use. For now, paste these: osgd.lib osgGAad.lib osgDBd.lib osgViewerd.lib osgTextd.lib osgUtild.lib OpenThreadsd.lib
- Notice that all these library names are appended with a ‘d’.
- Now the Debug mode is set up. Select the Release configuration and follow the same steps, except that the library names should NOT have a ‘d’ at the end, and in the Preprocessor Definitions change “_DEBUG” to “NDEBUG”.
- Visual Studio should now be set up.
- Finally, you need to test it.
- Into your C++ file, you need to copy some valid OSG code.
- Many test their installation with osgViewer.cpp which can be found in OSG’s source.
- If you don’t have the source or want a quicker method, go to this tutorial.
- There are links at the bottom to the full source for the tutorial. Copy the text into your file.
- Compile and run. You should see two colored pyramids that you can rotate with your mouse.
- Now that it’s installed and you have a working project, you can use this project as a basis for all your OSG projects.
And that’s it. Hopefully the tutorial wasn’t too simplistic. This is the quickest way I know how to install it on Windows. If you want to install from source, try some of the links below.
This tutorial is based on the following tutorials and posts
- Basic tutorial – current, a source installation tutorial.
- Paul’s Tutorial – current, a source installation tutorial.
- My Post – I posted about my problems getting it to work. The respondents were quite helpful on a number of subjects.
Edit (March 20, 2010):
Due to increasing volumes of spam, I must begin closing comments after a certain period. I know several of you have asked questions via the comments, and I’m sorry you won’t be able to do that anymore. You should visit the OSG Forums for further support and more up-to-date information.
May 13, 2009 | 5:16 PM
Categories: Graphics, How To, Programming

Really good instructions – thank you.
A couple of small things:
11.g. The C++ option does not appear until you add a C++ file, so you might like to move the addition of the test file to before this step.
11.n. For the file osgGAad.lib, I had to use osgGAd.lib and osgGA.lib
thank you,you help me a lot
Thank you! It has been useful! :)
The samples directory variable should point to the Data directory, right? So:
# Name: OSG_SAMPLES_PATH | Value: %OSG_ROOT%\share\OpenSceneGraph\bin
# Name: OSG_FILE_PATH | Value: %OSG_ROOT%\samples\OpenSceneGraph-Data-2.8.0
would be
# Name: OSG_SAMPLES_PATH | Value: %OSG_ROOT%\samples\OpenSceneGraph-Data-2.8.0
# Name: OSG_FILE_PATH | Value: ??
What is that FILE_PATH for?
Its indeed a great info..thanks! Following your steps, I got OSG working on VS 2005 (no sp installed) in Release config, but I have linker errors with Debug confi, trying to figure out the issues, will post when done.
I think the OSG_FILE_PATH value should be:
“%OSG_ROOT%\samples\OpenSceneGraph-Data-2.8.0;%OSG_ROOT%\samples\OpenSceneGraph-Data-2.8.0\Images”
it is so explicit that everyone can do it perfectly.
Thanks very much for the help. I followed your steps and got the OSGBasicGeometry project to compile straight away. I am certain that you saved me countless hours of frustration!
Hey, this is great! Was really helpful, now I have OSG installed using Visual Studio 2008 in Windows 7 RC. I was able to ran both the cow and the pyramids at the end. Thanks!
Now I can begin working in my VR project ^_^
hi,
i followed all the instruction and finally installed the osg and and able to run the cow and other objects….but when i tried to make my own program and compiled it the VS gave an error
“cannot open input file ‘osgGAad.lib”
when i saw the lib folder of installation directory there is no ‘osgGAad.lib’ file but there exists a ‘osgGAd.lib’ file……
so plz help me what to do now …..
Thank you!
Unfortunately, I got stucked in step 0 (10):
where it says
“warning: could not find plugin to read objects from file “cow.osg”
osgviewer: No data loaded”
It doesn’t matter if I put the full path of cow.osg or not.
What can be the problem? Any idea please? [I haven't come up with a solution thru googling :'( ]
@Knight.ist
Sorry dude, I don’t even have OSG installed anymore. My only suggestions are that you make sure you have the same versions and files as I mention here and to go back over the instructions to make sure you did everything it said.
@Everyone
Heed the comments about replacing “osgGAad.lib” with “osgGAd.lib”. I don’t remember exactly, but I think they are right, as far as typos go. I just don’t have the time to test it myself, so be sure to read the comments if you’re having problems.
@ pankaj
I met the same situation like you. Just remove “a” in “osgGAad.lib” , then it will going well.
Hi,
this tuto is nice.
I succeeded in installing OpenSceneGraph….
And now I need some tutos of OSG : it is the first time I try to code 3D application.
Please Help me ….!!!!
@Cube
It’s a lot more complicated than simply installing some 3D software. You need to get a basic understanding of how 3D graphics work in general (Google it). And you can try following some general tutorials, or get a book at the library on OpenGL. Don’t forget that there are Open Scene Graph tutorials here. Good luck! You’ve got a lot of work ahead of you.
During Installation in the command prompt i entered osgviewer cow.osg but got “no data loaded” Could anyone help me.
Thanks very much for this step-by-step guide. Not being an up-to-date programmer, your instructions were easy to follow, and ensured I didn’t miss anything.
I have modified this a little and made it a wee bit better. Here are my modifications.
Since I keep all my projects in C:\Projects, I extracted the debug and release zip files in C:\Projects and named them d and r. So, OpenSceneGraph-2.8.2d (for debug) and similarly ….2.8.2r (for release).
I created the OSG_ROOT env variable and set it to “C:\Projects\OpenSceneGraph-2.8.2″ (without the r/d at the end).
Then I created OSG_BINR_PATH (for release), OSG_BIND_PATH (for debug), similarly OSG_LIBR_PATH, OSG_LIBD_PATH, OSG_INCLUDER_PATH, and OSG_INCLUDED_PATH. I set each one of these as such
e.g. OSG_LIBD_PATH = %OSG_ROOT%d\lib
OSG_LIBR_PATH = %OSG_ROOT%r\lib
After setting up all six env variables as such, I used the release env vars in the release configuration profile in visual studio, and the debug env vars in the debug configuration profile.
I added both BINR and BIND env vars to the path.
Extracted the samples to the debug OSG_ROOT (just preference, you can extract it anywhere you want) and set the SAMPLES env var appropriately.
Everything seems compiling and executing properly for me (in debug and release) :)
I hope someone finds this useful.
Your Point 9 seems wrong.
My Windows don’t understand “osgversion”.
I checked my OSG/bin folder. i only have a “osgversiond.exe”.
After i typed “osgversiond” it showed my version.
I’m using VS2008. (Downloaded another package)
Excellent little tutorial – well done and thanks. I have install and verified OSG under Windows 7 – and was attempting to build the sample application in Visual Studio 2008.
Everything went swimmingly, until I tried to actually launch the built application from Visual Studio. I get a sialog box saying “The application was unable to start, click ok to continue”.
Inside the trace in studio i see the
“‘demo1.exe’: Loaded ‘C:\Windows\System32\osg55-osgd.dll’
as the last dll loaded. Same thing happens when I try to run the exe outside studio, and even when I copy the exe into the openscenegraph bin folder and try to run it from there.
Any tips appreciated!
(I am able to run the standard samples)
Bonjour,
j”ai un projet à réaliser avec OpenScenGraph et je dois l’installer. en fait, j’ai trouvé des difficultés d’installation alors j’ai fair réference à ce tuto qui m’apparait un peu plus facile à exploiter. Juste je voudrai savoir ou je peux trouver l’archive de data-set car le lien en question ne marche pas?
veuillez me communiquer une réponse SVP?..
Pardonnez-moi, je ne savent pas à quel lien vous vous référez. Je n’avais pas suivi OpenSceneGraph depuis que j’ai signalé ceci. Vous aurez probablement plus de succès rechercher des réponses sur les forum du projet.
A good tutorial. thank you. 1 addition: I had an error compiling in debug mode as MSVC 2005 stated that debugging information was not included though debug information was requested.
Under project properties->linker->Debugging->Generate Debug Info:
Choose: Yes (/DEBUG)
Is anyone having problems with Debug mode in MSVC 2005? I can run in release mode but I can not enter debug mode and I can not run the debug mode version. Any help would be greatly appreciated.
My error is:
application failed to initialize properly
LDR: LdrpWalkImportDescriptor() failed to probe C:\Program Files\OpenSceneGraph-2.8.2\bin\osg55-osgd.dll for its manifest, ntstatus 0xc0150002
Debugger:: An unhandled non-continuable exception was thrown during process load
The program ‘[17408] exampleOsg1.exe: Native’ has exited with code -1072365566 (0xc0150002).