Sei sulla pagina 1di 9

Installing OpenSceneGraph (OSG) from pre-compiled binaries on Windows

Posted on February 21, 2012 by Ioanna Hi again! Since I am currently getting my hands dirty with OpenScenceGraph for my thesis project, I thought that it would be useful to keep track of some basic steps and additionally share information that might help some of you in future. First of all what is OpenSceneGraph (or else OSG) ? As mentioned in the OSG website, OpenSceneGraph 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 modeling. It is written entirely in Standard C++ and OpenGL. It runs on most operating systems such as all Windows platforms, OSX, GNU/Linux. In general, OpenSceneGraph is well established as a world leading scene graph technology, used widely in vis-sim, space, scientific, oil-gas, games and virtual reality industries. Some facts 1. OpenSceneGraph is distributed in two main forms; Source code and Binaries. Frequently, several OpenSceneGraph versions are released (tip: download a Stable Release). - Source code release: is the .zip file (such as OpenSceneGraph-X.X.X.zip) containing the source code *OR* the folder containing the source code which can be checked out via SVN. - Binaries release: the binaries are divided into two versions; Debug and Release. In general the difference between a Debug and a Release build is that the Debug is basically for the developer and the compiler code optimization is OFF, whereas the Release is for the client to whom the application will be distributed and the compiler code optimization is ON. You can have a detailed look and download the OpenSceneGraph release versions here. 2. It is obvious that a C++ compiler is needed for developing OSG applications. It is a common practice to use Visual Studio IDE for developing OSG projects on Windows and gcc compiler for use on Linux respectively. Have a look here here for more options.

Windows Installation
Before continuing with the description of the installation of OpenSceneGraph on Windows, make sure that you have Visual Studio installed on your computer. I have Visual Studio 2008, Service Pack 1 (VS9 SP1) installed on my OS which is Windows 7, x86 32-bit. Nevertheless, it has been reported that by following similar steps, OSG has been successfully installed on previous versions of VS and Windows (such as Visual Studio 2005 and Windows XP and also Visual Studio 2010 and Windows 7). Be careful though to download the correct OpenSceneGraph release.

Installation in Steps
Step #1: Download OpenSceneGraph binaries and Samples Go here and download the Debug and the Release build version of OpenSceneGraph depending on you OS and your Visual Studio version. For example I downloaded the following: OpenSceneGraph-3.0.1-VS9.0.30729-x86-debug-12741.7z and OpenSceneGraph-3.0.1-VS9.0.30729-x86-release-12741.7z which can be found under Microsoft Windows x86 32-bit, OSG version 3.0.1, Visual Studio 9 (SP1). Additionally download the Samples Dataset (e.g. OpenSceneGraph-Data-3.0.0.zip) offered by OSG from here. Step #2: Uncompress the folders with 7-zip If you dont have 7-zip installed, I would recommend to download it from here and install it and then unzip the previous folders. I am suggesting 7-zip because it can handle .7z formats. Step #3: Preparing the installation directory Create a new folder named after the OSG version you are about to install (e.g. OpenSceneGraph-3.0.1) inside Program Files (preferably). Then the C:\Program Files\OpenSceneGraph-3.0.1 will be the root of your installation. Afterwards open the uncompressed Debug version of OSG and copy all the contents and paste them to the root directory (OpenSceneGraph-3.0.1). Inside the root, you should now see that it contains the folders: bin, doc, include, lib, and share. Then open the uncompressed Release version of OSG and copy all the contents and paste them to the root directory. In case the system asks you to overwrite a *file*, click NO. Create a new folder in the installation directory called samples and copy the uncompressed folder that contains the OSG Data (e.g. OpenSceneGraph-Data-3.0.0) and paste it in there. You will eventually have C:\Program Files\OpenSceneGraph3.0.1\samples\OpenSceneGraph-Data-3.0.0 as a path for the data.

The overall stucture of the installation directory should look like: The root directory: C:\Program Files\OpenSceneGraph-3.0.1 Inside the root directory (after merging Debug and Release versions): C:\Program Files\OpenSceneGraph-3.0.1\bin C:\Program Files\OpenSceneGraph-3.0.1\doc C:\Program Files\OpenSceneGraph-3.0.1\include C:\Program Files\OpenSceneGraph-3.0.1\lib C:\Program Files\OpenSceneGraph-3.0.1\samples C:\Program Files\OpenSceneGraph-3.0.1\share Inside samples directory ( the data that are offered by OSG for testing): C:\Program Files\OpenSceneGraph-3.0.1\samples\OpenSceneGraph-Data-3.0.0 Step #4: Make Windows recognize the installation directory by setting the environment variables Right click on Computer and then click on Properties. Then a window will appear containing information about your system and some options on the left side, there click on Advanced system settings. A new window will appear about System Properties, go to the advanced tab and there click on Environment Variables button. Again a window will popup, we are interested in the System Variables. Click on new button for inserting a new environment variable. Click on edit button for modifying an already existing environment variable. In a few words insert the following: a. Click on new button and give the variable name OSG_ROOT and give the variable value C:\Program Files\OpenSceneGraph-3.0.1 b. Now do the same for several other new environment variables, 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-3.0.0

c. We will now modify an existing environment variable. - Select the environment variable named Path - Click on the edit button - After the final semi-colon, add %OSG_BIN_PATH%;%OSG_SAMPLES_PATH%; - Apply your changes and close the windows, and now the environment variables are set. - Test that if the steps were correct by: go to Run, type cmd, a terminal will appear and there type echo %OSG_ROOT% and hit the enter key. The terminal should display the path to your installation directory.

Step #5: Test that Windows run your freshly installed OpenSceneGraph a. Open a terminal as you did before (Run, cmd) and type osgversion . This should return to you the version of openscenegraph that is installed on your machine, e.g. OpenSceneGraph Library 3.0.1 b. Then test that the OpenSceneGraph-Data (the samples) have been installed correctly as well. In the same terminal type osgviewer cow.osg . A cow model will appear at your screen. Hit the F key to go form full screen to window view. Finally, hit the ESC key to exit.

Step #6: Set-up Visual Studio to start developing a. Open Visual Studio b. Go to File, then click on New and then click on Project

c. A window will appear like the one show in the image below. Select an Empty Project under the Visual C++ branch, then insert a name for your future project (e.g. osgdefault) and then click on OK.

d. Now your new project (e.g. osgdefault) is loaded on Visual Studio (VS) and your project appears in the following form on the top left side of Visual Studios Interface.

Download the BasicGeometry.cpp file or another .cpp file that makes use of OpenSceneGraph of your choice, and right click on Source Files, then click on Add, then

on Existing Item.. and select the .cpp file you downloaded before and click on Add. After performing the above steps the following structure should appear on the top left side of VS. We insert a .cpp file so that in configuration settings later on, the C/C++ options appear (see next step for more).

e. Now right click on the project (e.g osgdefault) and then click on Properties. A window will appear the one displayed below.

This window provides Debug and Release configuration options (dropdown menu). At first we will tune the settings for Debug configuration of VS, and afterwards for Release. DEBUG Configuration 1. Select Debug as Configuration. 2. Then click on Configuration Properties so that the entire structure is visible like in the image above. 3. Click on C/C++ and then on General 4. Paste next to Additional Include Directories this: $(OSG_INCLUDE_PATH) 5. Click on C/C++ and then on Preprocessor 6. Paste next to Preprocessor Definitions these: WIN32;_WIN32;_DEBUG 7. Click on Linker and then on General 8. Paste next to Additional Library Directories this: $(OSG_LIB_PATH) 9. Click on Linker and then on Input 10. Paste next to the Additional Dependencies these: osgd.lib; osgGAd.lib; osgDBd.lib; osgViewerd.lib; osgTextd.lib; osgUtild.lib; OpenThreadsd.lib; RELEASE Configuration (differences only in steps 1, 6, and 10)

1. Select Release as Configuration. 2. Then click on Configuration Properties so that the entire structure is visible. 3. Click on C/C++ and then on General 4. Paste next to Additional Include Directories this: $(OSG_INCLUDE_PATH) 5. Click on C/C++ and then on Preprocessor 6. Paste next to Preprocessor Definitions these: WIN32;_WIN32;NDEBUG 7. Click on Linker and then on General 8. Paste next to Additional Library Directories this: $(OSG_LIB_PATH) 9. Click on Linker and then on Input 10. Paste next to the Additional Dependencies these: osg.lib; osgGA.lib; osgDB.lib; osgViewer.lib; osgText.lib; osgUtil.lib; OpenThreads.lib; f. The Visual Studio is now set to support this OSG project. Enjoy! # Are there any other guides on how to install OSG on Windows ? The most helpful guides that I have encountered so far are the following: 1) http://dwightdesign.com/2009/05/installing-openscenegraph-280/ 2) http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStud io I have tried both but I would recommend the first one to someone that needs a simpler version of installation. My post is based on that guide and the only difference is the more detailed explanation of steps. Nevertheless if you would like to try set up OSG with CMake, the second guide will do the job!

I did the same thing, had the same problem. Go back into project properties where u linked all the directories, look in the top right and click Configuration Manager Under Platform where it says Win32 select the dropdown box and click New. There should be an option for x64. Select that close all those windows, clean your solution, and it should build fine

Potrebbero piacerti anche