This guide describes how you can use FreeSG to compile an application using Microsoft Visual Studio 2008. It also describes the procedure for compiling FreeSG itself under Visual Studio. It assumes that you already have the Microsoft Windows SDK (or "Platform SDK") installed on your system.

Note: There are silly bugs in the <math.h> of Visual Studio 2005 which prevent proper compilation using single precision arithmetic. If you are using Visual Studio 2005, you will have to either upgrade or compile FreeSG for double-precision arithmetic.

Installing FreeSG

Get the latest FreeSG Windows binary package from the download page. You can unpack the archive to a location such as C:\Program Files\FreeSG.

Start Visual Studio and bring up Tools / Options. Select Projects and Solutions / VC++ Directories. In the Show directories for field, select the option Include files. If you have unpacked the FreeSG SDK package into C:\Program Files\FreeSG, for example, insert the line:

  C:\Program Files\FreeSG\include

Now select Show directories for / Library files and insert the line:

  C:\Program Files\FreeSG\lib
Installing Agar

FreeSG is built on top of the Agar library. Precompiled binary packages of Agar are available from the Agar download page and are installed in the same way as FreeSG. See the Agar installation instructions.

It is strongly recommended that you install a version of Agar compiled with threads support.

Creating a FreeSG application in Visual Studio

You can now create your application. In the Application Wizard, set Application type to Console application, check the Empty project box and click Finish.

In the Solution Explorer, go to Properties from the popup menu of your project. Click on Configuration Properties / Linker / System and set the SubSystem parameter to Windows (/SUBSYSTEM:WINDOWS). Click on Configuration Properties / Linker / Input, and add the following to the Additional Dependencies field:

  freesg.lib
  ag_gui.lib
  ag_core.lib
  SDL.lib
  SDLmain.lib
  opengl32.lib
  freetype.lib

If you are using the nofreetype flavor of the Agar SDK, remove the freetype.lib line.

Add a new C++ file to Source Files in the Solution Explorer, such as main.cpp. The application should now compile and run properly. See the ./demos directory of the FreeSG source for some example applications.

Note: If you want your application to be portable to other operating systems and other development environments, consider the BSDBuild utility. It can even generate project files for you.

Compiling FreeSG itself with Visual Studio

If you are not using the precompiled SDK and would like to compile FreeSG yourself, look for the project files included in the .\ProjectFiles\ directory in the FreeSG source. Locate the .zip file matching your Visual C++ release, for example vs2005-windows.zip will work with all Visual C++ 2005 editions. There are also some flavors such as nothreads, which disable thread safety and nofreetype which does not depend on FreeType.

Unpack the archive into the FreeSG source directory (e.g., such that FreeSG.sln will unpack in the same directory as FreeSG's README file).

Open FreeSG.sln with Visual Studio and you should now be able to compile the toolkit. Once FreeSG is compiled, run INSTALL-SDK.EXE in the root of the FreeSG source directory to install the libraries on your system. By default, they are installed into C:\Program Files\FreeSG.


Csoft.net ElectronTubeStore.com