wiki:BuildVS2005Cygwin

Building OpenSG 1.x using Visual Studio 2005 and Cygwin

  1. Install Visual Studio 2005. You can either use the free version “Express” (available for free download from Microsoft) or one of the non-free versions.
  2. When using the “Express” edition, also download and install the “Platform SDK” from Microsoft. Other versions of Visual Studio come with the Platform SDK already integrated.
  3. Install Cygwin. Cygwin is available for free download from http://www.cygwin.com/. In the setup dialog, click on the “View” button until you get the “full” package list. Install the following additional packages: “bison”, “cvs”, “flex”, and “make”.
  4. Open the file “cygwin.bat” in the root directory of the Cygwin installation with a text editor. You have to call a couple of batch files from the Cygwin batch file to set several environment variables and to update the search pathes for includes, libraries and executables:
    • Call the batch file “vcvarsall.bat” located under “VC” in the Visual Studio installation directory. This makes sure that you are able to access the includes, libraries and executables that come with Visual Studio.
    • When you installed the “Platform SDK”, call the batch file “SetEnv.Cmd” in the Platform SDK installation directory. This makes sure that you are able to access the includes, libraries and executables that come with the Platform SDK. You have to add the parameter “/RETAIL” when you call the batch file, otherwise you will get the debug versions of the libraries.

So for example, on my machine the Cygwin batch file looks like this:

@echo off
@call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"
@call "C:\Program Files\Microsoft Platform SDK\SetEnv.Cmd" /RETAIL
d:
chdir d:\cygwin\bin
bash --login -i

When saving, make sure that you save the file as a plain text document!

  1. Start the Cygwin shell. You have to enter all the commands in the following text in this shell.
  2. Go to the “bin” folder located in the Cygwin root directory. Rename the file “link.exe” to “link.bak.exe”. To do this, enter the following commands in the shell:
    cd /usr/bin
    mv link.exe link.bak.exe
    
    This is necessary because we need to use the Microsoft linker instead of the linker provided by Cygwin. Unfortunately, the Microsoft linker is also called “link.exe”, and it is coming after the Cygwin linker in the search path. (Notice: If you change anything on your Cygwin installation, i.e. update, add, or remove packages, make sure to repeat this step afterwards, because the setup recreates the “link.exe”.)
  3. Download OpenSG from the CVS. When downloading OpenSG for the first time, you have to enter the following commands (they create a new directory called “OpenSG” in the current directory and download the OpenSG source code into that directory):
    cvs -d:pserver:anonymous@opensg.cvs.sourceforge.net:/cvsroot/opensg login
    cvs -z3 -d:pserver:anonymous@opensg.cvs.sourceforge.net:/cvsroot/opensg co -P OpenSG
    
    When prompted for a password, simply press “Return”. When you need to update your local version of OpenSG with the current version in the CVS later on, you simply go into the OpenSG root directory and enter the following command:
    cvs -z3 update -d -P
    
  4. Unzip the file “OpenSG\dist\win\supportlibs.zip”. Do not unzip this file anywhere into the OpenSG directory tree, because the OpenSG build system copies all header files it finds in the directory tree into the installation directory, and the header files of the STLPort library contained in the supportlibs conflict with the header files of Visual Studio. The supportlibs zip file contains precompiled versions of the JPEG library (http://www.ijg.org/), the JPEG2000 library (http://www.ece.uvic.ca/~mdadams/jasper/), the PNG library (http://www.libpng.org/pub/png/), the TIFF library (http://www.libtiff.org/), and the GLUT library (http://www.xmission.com/~nate/glut.html). Of course, these libraries are only needed when you need support for these image formats and the GLUT. You can also use your own versions of these libraries, but I strongly recommend using the precompiled versions contained in OpenSG.
  5. Now you have to configure OpenSG. I recommend creating a special script file, because you have to configure OpenSG every once in a while. For example, my batch file looks like this (it is located in the OpenSG root directory):
    export JPEGDIR=`cygpath -u "D:\pdaehne\supportlibs"`
    export JASPERDIR=`cygpath -u "D:\pdaehne\supportlibs"`
    export PNGDIR=`cygpath -u "D:\pdaehne\supportlibs"`
    export TIFDIR=`cygpath -u "D:\pdaehne\supportlibs"`
    export GLUTDIR=`cygpath -u "D:\pdaehne\supportlibs"`
    ./configure --with-compiler=cl.net2005 --prefix=BUILD --enable-win-localstorage --enable-gif --with-jpg=$JPEGDIR --with-jasper=$JASPERDIR --with-png=$PNGDIR --with-tif=$TIFDIR --with-glut=$GLUTDIR
    
  6. Go into the directory “OpenSG\Builds\i686-pc-cygwin-cl.net2005” and enter the following commands:
    make opt
    make install
    
    The first of these commands compiles a release/optimized version of OpenSG. The second installs the OpenSG headers into “OpenSG\Builds\i686-pc-cygwin-cl.net2005\include” and the libraries into “OpenSG\Builds\i686-pc-cygwin-cl.net2005\lib\opt”. You also have to enter these commands everytime you change anything in the OpenSG source code, or when you update the source code from the CVS. In this case you should call “make update” instead of “make install”, because “make update” only copies the changed header files to the “Builds” directory. This is much faster, and in many cases it prevents a complete recompilation of your own code based on OpenSG.
Last modified 8 years ago Last modified on 01/17/10 01:11:44