How to compile OpenSceneGraph 2.x using MinGW/MSYS

This tutorial will explain how to compile OpenSceneGraph using MinGW with the source code from the SVN.

Last update: 11/03/2010

Notes: Switched from MinGW to MinGW provided by Qt/Trolltech for better compatibility with Qt examples.


Before following this tutorial, make sure that you have read the the previous two tutorials:

The first one explains how to setup a MinGW/MSYS development environment, the second one explains how to install commonly used libraries in MinGW (most of them are required to build OpenSceneGraph).

Additional dependencies


Qt 4.6.2


  • CMake (cmake-2.8.0-win32-x86.exe)
  • Install using default settings

Download the sourcecode from the OSG SVN

Preparing OpenSceneGraph (CMake)

  • Launch Cmake
  • Set “Where is the source code” to: C:/Projects/OpenSceneGraph/OpenSceneGraph-SVN
  • Set “Where to build the binaries” to: C:/Projects/OpenSceneGraph/OpenSceneGraph-Build
  • Click Configure
  • Choose MSYS Makefiles (Use default native compilers) and click on Finish
  • Enable “Simple View”
  • Set “ACTUAL_3DPARTY_DIR” to: C:/mingw
  • Set “CMAKE_BUILD_TYPE” to: Release
  • Set “CMAKE_INSTALL_PREFIX” to: C:/Projects/OpenSceneGraph/OpenSceneGraph-Bin
  • Click Configure
  • Enable “Grouped View”
  • Most of the libraries should’ve already been found, however there are a few you need to add manually
  • Set “TIFF_LIBRARY” to: C:/mingw/lib/libtiff.dll.a
  • Set “SDL_INCLUDE_DIR” to: C:/mingw/include/SDL
  • Set “SDL_LIBRARY” to: C:/mingw/lib/libSDL.dll.a
  • Set “QT_INCLUDE_DIR” to: C:/Qt/4.6.2/include
  • Set “QT_MOC_EXECUTABLE” to: C:/Qt/4.6.2/bin/moc.exe
  • Set “QT_QASSISTANTCLIENT_LIBRARY” to: C:/Qt/4.6.2/lib/libQtAssistantClient4.a
  • Set “QT_QMAKE_EXECUTABLE” to: C:/Qt/4.6.2/bin/qmake.exe
  • Set “QT_MAIN_LIBRARY” to: C:/Qt/4.6.2/lib/libqtmain.a
  • Set “QT_UIC_EXECUTABLE” to: C:/Qt/4.6.2/bin/uic.exe
  • Set “LIBXML2_INCLUDE_DIR” to: C:/mingw/include/libxml
  • Set “LIBXML2_LIBRARIES” to: C:/mingw/lib/libxml2.a
  • Set “GLUT_LIBRARY” to: C:/mingw/lib/libglut.dll.a
  • Set “GIFLIB_LIBRARY” to: C:/mingw/lib/libgif.a
  • Set “FREETYPE_INCLUDE_DIR” to: C:/mingw/include/freetype2
  • Set “FREETYPE_INCLUDE_DIR_freetype2” to: C:/mingw/include/freetype2
  • Set “FREETYPE_INCLUDE_DIR_ft2build” to: C:/mingw/include/freetype2
  • Set “FFMPEG_ROOT” to: C:/Projects/3rdParty/ffmpeg
  • Set “SDLMAIN_LIBRARY” to: C:/mingw/lib/libSDLmain.a
  • Set “GLUT_glut_LIBRARY” to: C:/mingw/lib/libglut.dll.a
  • Click Configure
  • Click Configure
  • Click Generate

Building OpenSceneGraph

  • Open MSYS
  • Change your directory: cd /c/Projects/OpenSceneGraph/OpenSceneGraph-Build/
  • Type “make” and hit enter
  • Type “make install” and hit enter
  • Done! (OpenSceneGraph should now be installed in:

Additional resources

7 responses

  1. Thanks for this Laurence!

    John Montgomery January 12th, 2010
  2. Thanks Laurence! Really useful How To :)

    Alvaro – February 12th, 2010
  3. Thank you for the nice information! That is exactly what I was looking for. I was trying to use the pre-built libraries (.lib files for visual studio) with many linking problems. That would be nice if you add an entry to wiki: for your MingWin binaries. The VS9 compiled libraries can not be directly used with MingWin I guess, I appreciate if you share any experience/solution regarding this. Thank you again!

    dashesy – February 23rd, 2010
  4. @dashesy Unfortunately it is not possible to mix libraries from different compilers (Ok, there are some exception with C libraries, but that probably won’t apply for osg). Actually Jean-Sebastien Guay added a link here Did you used the pre-built libraries from ? The VisualStudio 9 (2008) SP1 files should work (be sure to update your compiler), if they don’t what error message do they show?

    Laurence Muller February 23rd, 2010
  5. Just a small update: The section “Patching OpenSceneGraph” is not anymore required if you’re using the source code from the SVN (trunk). It has already been patched. Discussion: Bugfix:

    Laurence Muller February 23rd, 2010
  6. Thanks for the info! I was going to use dlltools to make some .a files from .lib files before I found your blog in the same link that you provided. I think similar to VS9 and VS8 there should be an official release for MingWin specially because many people like me use OSG with QT and are lazy not to build from the source themselves! When I use the release version from here: I get so many “undefined reference to” problems in the linking like (…/osg/OpenSceneGraph-2.8.2/include/osg/Referenced:147: undefined reference to `imp_ZN11OpenThreads6AtomicppEv’ or ‘_imp__ZN3osg10ReferencedD2Ev’ or so many others) I tried both with “-L\({OSGHOME}/lib -l\){libname}” and also without “-l” option with $${libname}.lib, with no luck. I appreciate if you shed some light into this. However with .a files that you have provided the build works like a charm. I am using gcc 4.4.0 BTW

    dashesy – February 23rd, 2010
  7. Hi dashesy, it would be nice if OSG would provide offical binaries build with MinGW (Qt/Trolltech are providing both VS and MinGW binaries for windows users) For the time being I will just post my own builds build with GCC 4.4.0 (from Trolltech). About your error, it is not possible to mix C++ libraries from different compilers.

    Laurence Muller March 12th, 2010