Archive for the ‘osg’ Category

How to Compile/Install osgAudio for Windows

Sunday, September 26th, 2010 by Phillip Napieralski

I decided to make this post out of necessity. OsgAudio is not well-documented at this point. I probably invested a solid 5 hours trying to get it working correctly.

Pre-requisites

You should already have the following:

  • Microsoft Visual Studio (any recent version)
  • OpenSceneGraph (and, at least, the ability to compile/run any OpenSceneGraph example)

Handling Dependencies

OsgAudio’s wiki mentions there are the following dependencies:

  • OggVorbis
  • OpenAL
  • FreeALUT

Let’s handle Ogg and Vorbis first:

  1. Create a folder to store all the dependency’s source code (I called it ‘source’)
  2. Create another folder to store all the compiled source, which will be in the form of an SDK (I called it ‘bin’)
  3. Navigate to OggVorbis and download libogg-x.x.xx.zip and libvorbis-x.x.xx.zip (found in the developer section).r
  4. Extract both zip files to your ‘source’ folder.
  5. Enter your libogg-x.x.xx directory and go into the ‘win32′ directory.
  6. Go inside the directory corresponding to your version of Microsoft Visual Studio
  7. Open libogg_dynamic.sln
  8. Build the solution
  9. Inside the ./libogg-x.x.xx/win32/VSxxx/ directory, there should now be a win32/release directory (if not, make sure to build the release version of the code)
  10. Inside your ‘bin’ directory, create a folder called libogg. Inside this folder, create a ‘lib’ and an ‘include’ directory
  11. Copy the libogg.lib and libogg.dll files from the win32/release directory into your new ‘bin/libogg/lib’ directory
  12. Copy the ‘include’ folder from the libogg source folder and paste it to your newly created ‘bin/libogg’ directory

You can now build items that rely on the Ogg libraries. For example, let’s now build Vorbis:

  1. Similarly, navigate to your libvorbis-x.x.x folder and go in the win32/ folder.
  2. Open the dynamic solution and build the release version of libvorbis.

At this point, you WILL receive an error that ‘libogg.lib’ cannot be found. To fix this, do the following:

  1. Open up the solution file (libvorbis_dynamic.sln)
  2. In the top menu bar, navigate to ‘Tools->Options’
  3. On the left of the options window, navigate to ‘Projects and Solutions->VC++ Directories’
  4. On the right side, under ‘Show directories for:’ select ‘Library files’
  5. Create a new entry by selecting an empty spot in the white textbox area. Type-in/browse to the ‘lib’ directory you created for libogg.
  6. Now the same for ‘Include files’. Except type-in/browse to the include directory you copy/pasted for libogg.

After compiling libvorbis, create a folder in your ‘bin’ directory called ‘lib’ and copy libvorbis.dll, libvorbisfile.dll, libvorbis.lib and libvorbisfile.lib from the Win32/Release folder to the lib directory you created. As with libogg, copy the include folder to your bin/libvorbis directory.

GOOD! Now OggVorbis should be good to go. Let’s handle OpenAL and freeALUT.

  1. Navigate to OpenAL’s download page
  2. Install OpenAL (use OpenALInstaller) and it’s SDK (use OpenAL11CoreSDK).
  3. The OpenAL SDK will default to your ‘Program Files’ folder, keep this in mind for later use
  4. Back on the downloads page, click ALUT.
  5. Download freealut-x.x.x-bin and extract it to the ‘bin’ folder you created

At this point, you should have 4 different directories in the dependency ‘bin’ folder that you created. If not, shoot me a comment and I might be able to help.

Finally, let’s build osgAudio.

Building osgAudio

  1. Navigate to osgAudio’s download page and download osgAudio_xx_xx_xx.zip.
  2. Extract it to the ‘source’ folder you created earlier
  3. Rename the extracted folder to osgAudio_xx_xx_xx-PreCMAKE
  4. Download/Install CMAKE if you haven’t already
  5. Run CMAKE
  6. Click ‘Browse Source’ and select the osgAudio_xx_xx_xx-PRECMAKE directory
  7. Click ‘Browse Build’ and store it next to your other osgAudio folder but with a POSTCMAKE suffix ‘osgAudio_xx_xx_xx-POSTCMAKE’

At this point, when we run CMAKE (by clicking Configure), it will attempt to find the dependencies we compiled earlier. If it’s successful, we can then open up our osgAudio_xx_xx_xx-POSTCMAKE directory and build the solution it created. But, it likely failed.

Basically, for every RED box that appears in the settings list, you need to do something. As an example, here is a screencap of my settings:

osgAudio cmake settings

YAY! Now we have the solution file for osgAudio, but we STILL need to compile it!

  1. Open up your osgAudio_xx_xx_xx-POSTCMAKE directory and double-click osgAudio.sln to open it in Microsoft Visual Studio.
  2. If, for some reason, it complains about a missing library/include file. Navigate to Tools->Options and add the directory as we did with libogg and the other libraries.

After building the release version of osgAudio successfully, copy the lib and include folder from the source folder to the ‘bin’ folder you built earlier.

Your final directory listing SHOULD look something like this:

PHEW, that’s it!

Further Troubleshooting

I’m missing xxx.lib – Linker Error! Open up the solution file you are working with and go into Tools->Options. Then, on the left, navigate to ‘Projects and Solutions->VC++ Directories’. Use the interface to add your include and library directories (see screencap below):

If you are getting any other weird errors when building your own projects, you probably did not add the correct .lib files to link with. Fix this by doing the following:

  1. Open up your solution file
  2. On the top menu-bar, navigate to ‘Project->XX Properties’
  3. In the listing on the left, navigate to ‘Configuration Properties->Linker->Input’
  4. Under ‘Additional Dependencies’, add osgAudio.lib (for Release mode) or osgAudiod.lib (for Debug mode) as in the picture below

project-properties