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.
