Building FlightGear - Windows: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
Line 120: Line 120:
Going this route means that you must compile plib yourself by following the instructions below:
Going this route means that you must compile plib yourself by following the instructions below:


* '''Step 1''' - Download the latest plib source tarball from http://plib.svn.sourceforge.net/viewvc/plib/trunk.tar.gz and extract it in some location that is NOT in your FlightGear project root directory.  This will create a subdirectory named '''trunk''' which you may wish to rename to '''plib-svn''' or similar.
* '''Step 1''' - Download the latest plib source tarball from http://plib.svn.sourceforge.net/viewvc/plib/trunk.tar.gz and extract it in some location that is NOT in your FlightGear project root directory.  This will create a subdirectory named '''trunk''' which you may wish to rename to '''plib-svn'''. The remaining instructions assume that you did name it '''plib-svn'''


* '''Step 2''' - Double-click the file plib-svn\plib.dsw. This should launch Visual C++ which will ask if you want to convert the project file; answer "Yes to all" at the convert prompt.
* '''Step 2''' - Double-click the file '''plib-svn\plib.dsw'''. This should launch Visual C++ which will ask if you want to convert the project file; answer "Yes to all" at the convert prompt.


* '''Step 3''' - Build the debug version of the plib libraries first by setting the VC++ Solution Configuration for Debug and hitting the F7 key.
* '''Step 3''' - Build the debug version of the plib libraries first by setting the VC++ Solution Configuration for Debug and hitting the F7 key.
Line 135: Line 135:
   C:\FlightGear\plib
   C:\FlightGear\plib


* '''Step 5''' - Copy all of the files in your plib-svn directory that have the extensions "h", "lib" and "pdb" to the new plib directory under your FlightGear project root directory.
* '''Step 5''' - Copy all of the files in your '''plib-svn'' directory that have the extensions "h", "lib" and "pdb" to the new plib directory under your FlightGear project root directory.


== Getting OpenSceneGraph (OSG)==
== Getting OpenSceneGraph (OSG)==

Revision as of 17:05, 15 February 2010

1rightarrow.png See Building Flightgear for the main article about this subject.

NOTE: Some parts of these instructions do not work correctly at this time, due to changes in the underlying software libraries. This page is a work in progress. The instructions should now be usable for all but building jpeglib and installing FlightGear

This section describes how to build FlightGear on Windows using Visual C++ 2008 Express Edition (the "free" for personal use version). These procedures will be very similar if you have the full Visual Studio 2008 and mostly similar if you're using older versions of Visual C++.

Keep in mind that FlightGear is a large project with external dependencies and compiling it is not a task for novice users. If you just want to fly, we recommend you get the binary distribution and have fun. If you intend to get hip deep in the code, please proceed...

Requirements

Before you can compile FlightGear, you need to have the following installed on your computer:

C++ compiler

You may download the Express ("free" for personal use) version of Visual C++ 2008 from Microsoft. C++ Builder and Turbo C++ Explorer (by CodeGear, formerly by Borland) should work as well with some effort. We have not tried this.

Please note that when using MSVC++ Express, you'll probably want to download the full offline installation image file (iso) which -unlike the web installation- doesn't require any complicated and long-winded registration process. The direct link to the latest version (as of 11/2008) is [1] - after having downloaded the iso image, you'll either have to burn it or simply mount it in order to execute the installation.

You will also need the Platform SDK (Software Developer's Kit).

You can download the PSDK from http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en or http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

Detailed installation instructions are available here (and [2]).

CVS

FlightGear uses CVS (Concurrent Versions System) for version control. You will need a CVS client if you want to download the latest (development) source code for both FlightGear and SimGear. Traditionally, these are command line tools, but TortoiseCVS provides a graphic interface for Windows users. Download the installer for the latest stable version of TortoiseCVS, run the installer, using all of its default settings (the installation destination folder is up to you). It will ask you to restart the computer when it's finished <grumble>. Do that.

SVN

OpenSceneGraph (OSG) uses Subversion (SVN) for version control. You will need an SVN client if you want to use the latest (development) source code for OpenSceneGraph. TortoiseSVN provides a graphic interface for Windows users. Download the installer for the latest stable version of TortoiseSVN, run the installer, using all of its default settings (the installation destination folder is up to you).

Dependencies

FlightGear is dependent on quite a number of external libraries. You do not need to compile all of them yourself, but you will at least need to have their development version installed.

  • Boost
  • ALut, OpenAL and pthreads. These are listed here as one dependency because it's made available as a single package by a FlightGear project member.
  • zlib
  • jpeglib
  • Plib - portability libraries and scene graph.
  • OpenSceneGraph
  • SimGear - Simulation support libraries that are developed mainly by the same people who develop FlightGear, though it can be and is used for other purposes. If you are building FlightGear from CVS, you need the CVS version of SimGear. If you have strange FlightGear build errors, check that you have an up-to-date version of SimGear built and installed.

The dependencies are introduced in the steps below in roughly the order that you will need to get them.

Directory Structure

As noted above, FlightGear depends on several other software packages. The Visual C++ project files that are maintained in CVS for both SimGear and FlightGear assume that these dependencies can be found within a very specific directory structure. In these examples, the root of the FlightGear related directories is C:\FlightGear\. This part is actually up to you; you could choose a completely different name and drive location.

All other directories shown under this project root must follow the directory structure shown below:

 C:\FlightGear\boost_1_39_0\
 C:\FlightGear\simgear\
 C:\FlightGear\simgear\simgear\
 C:\FlightGear\install\msvc90\OpenSceneGraph\include\
 C:\FlightGear\3rdParty\include\
 C:\FlightGear\plib
 C:\FlightGear\flightgear

If you continue to follow the instructions in this wiki, you will end with the proper directory structure that is shown above.

Getting Boost 1.39.0

  • Step 1 - Download Boost packaged release Version 1.39.0 (about 188 MB) from

http://sourceforge.net/projects/boost/files/boost/1.39.0/boost_1_39_0.zip/download (direct link) or from the project releases page at http://www.boost.org/users/download/#releases

  • Step 2 - Extract the contents of the boost archive in your \FlightGear directory. This will create a subdirectory named boost_1_39_0 where the boost libraries and include files reside.

Getting "3rdParty" ALut, OpenAL and pthreads

Olaf Flebbe has provided an archive containing the following FlightGear dependencies:

 ALut
 OpenAL
 pthreads

Download the archive from http://www.oflebbe.de/FlightGear/3rdParty-2008-01-30.zip

Extract the archive in your FlightGear project root directory, C:\FlightGear\ in these instructions. This will create the directory 3rdParty under your project root directory.

Getting zlib

  • Step 2 - Extract the archive you downloaded in Step 1 in the "3rdParty" directory under your FlightGear project root directory.
  • Step 3 - As of zlib version 1.2.3, you must edit line 287 of the file "3rdParty\include\zconf.h" from "#if 1" to "#if 0" to avoid compiler errors when compiling SimGear against zlib.

Getting jpeglib

  • Step 2 - This is a simple way to compile that should work with all versions of MSVC.

Open a command prompt and navigate to the folder where you have extracted the sources. Type the following commands:

copy jconfig.vc jconfig.h
copy makefile.vc makefile

(this will copy the preconfigured Visual C configuration and makefile).

Then on the same command prompt type the following command to build the library:

nmake nodebug=1

Make sure that other projects will find your new files: Either copy jerror.h, jmorecfg.h and jpeglib.h to an include folder which is already defined (e.g. 3rdparty/include) or modify the individual project settings by adding the directory where you unpacked the jpeglib sources. The latter method is not advised.

Finally if you get the error:

makefile(11) : fatal error U1052: file 'win32.mak' not found
Stop.

then you need to add the switch /f <path> to point to the file Win32.Mak which resides in the above mentioned Platform SDK directory\Include. Make sure to enclose this path into double quotes if the path contains spaces.

Getting plib

You may download a prebuilt version of plib from http://www.oflebbe.de/FlightGear/plib-2007-04-16.zip (direct link) or visit Olafe's Compiling FlightGear page at http://www.oflebbe.de/FlightGear/index.html If you use this prebuilt, just extract the archive file's contents in your FlightGear project root directory. This will create the subdirectory plib.

The above plib package does not include debug libaries, only release. There have also been some bug fixes and changes to since that package was created, so you may wish to use the latest development version from SVN which you may download here http://plib.svn.sourceforge.net/viewvc/plib/trunk.tar.gz One annoying bug that was fixed caused joystick models to not be recognized automatically on Windows Vista (and maybe XP).

Going this route means that you must compile plib yourself by following the instructions below:

  • Step 1 - Download the latest plib source tarball from http://plib.svn.sourceforge.net/viewvc/plib/trunk.tar.gz and extract it in some location that is NOT in your FlightGear project root directory. This will create a subdirectory named trunk which you may wish to rename to plib-svn. The remaining instructions assume that you did name it plib-svn
  • Step 2 - Double-click the file plib-svn\plib.dsw. This should launch Visual C++ which will ask if you want to convert the project file; answer "Yes to all" at the convert prompt.
  • Step 3 - Build the debug version of the plib libraries first by setting the VC++ Solution Configuration for Debug and hitting the F7 key.

Build the release version of the plib libraries next by setting the VC++ Solution Configuration for Release and hitting the F7 key.

NOTE: as of this writing, 5 compile errors in 4 files will occur. In each case, a typecast of (char*) must be added in order to compile without error using VC++ 2008 (VC90).

  • Step 4 - Create the subdirectory plib in your FlightGear project root directory.

Example:

 C:\FlightGear\plib
  • Step 5' - Copy all of the files in your plib-svn directory that have the extensions "h", "lib" and "pdb" to the new plib directory under your FlightGear project root directory.

Getting OpenSceneGraph (OSG)

  • Intro

To build SimGear and FlightGear from CVS head, you'll usually need the latest version of OSG. OSG from SVN head might be the best choice.

  • Fetching "cutting edge" sources from SVN head

Use Tortoise SVN to fetch the lastest source of OSG. The URL for the project archive is http://www.openscenegraph.org/svn/osg/OpenSceneGraph/tags/OpenSceneGraph-2.9.6. The destination folder should be OpenSceneGraph under your FlightGear project root directory. All other options can be left alone and are good to go as default. Wait until all files are downloaded from SVN.

  • Dependencies

OSG depends on some external libraries from the GnuWin project
- Jpeg
- Png
- ZLib
Download these packages and unzip them (including the folder structure) to your FG project folder\3rdparty. If you do not intend to create debug versions of OSG you can remove all links to debug files and *-bcc.lib in ...\3rdparty\lib.

  • Preparing sources with CMake (generating project and solution files)

Get CMake for Windows. Extract all files from the archive to a folder of your choice (e.g. C:\DEV\CMake). Go to C:\DEV\CMake\bin and start cmake-gui.exe. Browse for the OSG source code (e.g. FlightGear project root\OpenSceneGraph) and enter this to the first line. Below this you'll find the path where to build the binaries. After entering the path to the souce code you'll find the same path here. Just add \build to this and you are now good to press Configure. If it did not happen before you'll now receive an information that your buld-folder was not found and cmake-gui asks you if it should be ceated for you. Press yes to do so. Next specify you installed compiler (e.g. Visual Studio 9 2008). Set Use default native compiler and press Finish.

cmake-gui is now configuring everything so that you can use VC9 with OSG sources. But before you can go on you'll need to tweak cmake a little bit. After pressing Configure the first time, many red lines will appear in the middle window which points you to settings where you can customise your build. Chnage the view from Simple view to Advanced view to achieve more detailed settings. Some settings must be reviewed (e.g. ACTUAL_3RDPARTY_DIR, CMAKE_INSTALL_PREFIX, etc.).

In permission-restricted environments (like Vista or Windows 7) do not set CMAKE_INSTALL_PREFIX to a restricted folder like c:\program files as this will not work and lead to many permission denied messages as cmake can't elevate your rights. Use a permission free folder instead.

If you are satisfied with your cmake-options press configure 2, 3 or 4 times until Generate becomes active. Press it and wait until cmake-gui has finished to creat all neccesary folders/files for proceeding in Visual Studio (VC).

  • Building in VC9

Switch to the folder Where to build binaries named before in cmake-gui and open the file OpenSceneGraph.sln with VC. Select your desired build type (Debug, Release, RelWithDebugInfo, MinSizeRel) and press F7 to build the project. It's time for some coffee as this process will take some time. After all is done (hopefully) without errors right click the INSTALL project and build it. This will copy your compiled files to their correct locations (CMAKE_INSTALL_PREFIX). Before you do that all files reside in your build folder and it's not recommende to use them from there.

  • Some additional words

The first compile run will take certain long time. After you finished the first build all further builds will work much faster. So updating SVN and recompiling the sources will not take too much time in the future. Just make sure: ALWAYS BUILD THE INSTALL PROJECT as this is part of the complete process. Without this your newly built files will stay in your build but not in your install folder.


  • Stable releases

You can however try and follow the building instructions from above to bet "cutting edge" with OSG. Or you can download the latest Windows binaries from this page: [3]

Get the archive(s) named "openscenegraph-all[...]". Get both the Release and Debug versions if you expect to do any debug builds of FlightGear. Otherwise, just the Release version should be fine.

  • Step 2 - Create a the following directure structure under your FlightGear project root directory: "install\msvc90\"

Example:

 C:\FlightGear\install\msvc90\

I have no idea why that directory structure was chosen, but that's what the MS VC++ project file(s) in FG CVS expect.

  • Step 3 - Extract the OSG archive(s) you downloaded in Step 1 in the directory you created in Step 2.
  • Step 4 - Rename the resulting "OpenSceneGraph-[version]" directory to simply "OpenSceneGraph".

This method is much more simple but the stable releases are far behind the actual development.

Getting and compiling SimGear

  • Step 1 - Navigate to the base folder for your FlightGear stuff; In this example, we've chosen "C:\FlightGear"

In Windows Explorer, select the "C:\FlightGear" folder and right-click on it. From the resulting pop-up menu, choose "CVS Checkout". On the "Module" tab, enter the following in the CVSROOT field:

:pserver:cvsguest@cvs.simgear.org:/var/cvs/SimGear-0.3

At the "Module" section near the bottom of the "Module" tab, click the "Fetch List" button. You will see some brief action and may see an error and a prompt for a password. Enter "guest" for the password (without the quote symbols). From the drop-down "Module" list, select "source" and click the "OK" button to begin the checkout.

  • Step 2 - Since all the source code will be downloaded into a directory called source, you will need to rename that directory to simgear.

Navigate to simgear\projects\VC90 and double-click on the file SimGear.vcproj. This should launch Visual C++ with the SimGear project loaded.

  • Step 3 - Build SimGear, either Release, Debug or both using VC++ 2008 (9.0)

Note: with the default settings, Visual C++ will yield many compiler warnings. Unfortunately, this is normal.

Getting and compiling FlightGear

  • Step 1

Make a base folder for your FlightGear stuff; In this example, we've chosen "C:\FlightGear"

In Windows Explorer, select the "C:\FlightGear" folder and right-click on it. From the resulting pop-up menu, choose "CVS Checkout". On the "Module" tab, enter the following in the CVSROOT field:

:pserver:cvsguest@cvs.flightgear.org:/var/cvs/FlightGear-0.9

At the "Module" section near the bottom of the "Module" tab, click the "Fetch List" button. You will see some brief action and may see an error and a prompt for a password. Enter "guest" for the password (without the quote symbols). From the drop-down "Module" list, select "source" and click the "OK" button to begin the checkout.

A directory with the name source will then be created with all of Flightgear's source code downloaded into it. Rename this directory from source to flightgear.

  • Step 2

Build either the Debug or Release version FlightGear as desired.

  • Step 3

TODO: Installation.

Checking out the FlightGear data

The binary distribution package contains data for only a small subset of the existing aircraft and other objects. The instructions below tell you how to obtain the full set of data, in their latest, greatest form.

Make a base folder for your FlightGear stuff; In this example, we've chosen "C:\FlightGear"

In Windows Explorer, select the "C:\FlightGear" folder and right-click on it. From the resulting pop-up menu, choose "CVS Checkout...". On the "Module" tab, enter the following in the CVSROOT field:

:pserver:cvsguest@cvs.flightgear.org:/var/cvs/FlightGear-0.9

At the "Module" section near the bottom of the "Module" tab, click the "Fetch List" button. You will see some brief action and may see an error and a prompt for a password. Enter "guest" for the password (without the quote symbols). From the drop-down "Module" list, select "data" and click the "OK" button to begin the checkout.

The result of the checkout is a directory called C:\FlightGear\data. To use this data directory with the FlightGear program, you can either (a) move it to C:\Program Files\FlightGear\ directory or (b) direct FlightGear to the actual location of this data directory from the command line or within the fgrun launcher application.

External links