Building FlightGear 0.9.10

index

FOR A LATER MSVC7 BUILD, OF THE CVS SOURCE, WITH OSG, SEE fgfs-036.htm

Building FlightGear 0.9.10, and its dependant components - 24 March, 2006

This is a build using Microsoft Visual Studio NET 2003, version 7.1, in Windows XP SP2. The build information below covers the Folder Structure, OpenAL, PLIB, SimGear, and finally the last important part, FlightGear itself. What a DIFFERENCE a day makes! Simgear no longer includes zlib, so this must be added to the list ...

Jump to Folders OpenAL zlib plib SimGear FlightGear Quick Links

Folder Structure

As usual, there are MANY ways to do this, but the following DEPENDS on having this folder structure ... Since this is FlightGear 0.9.10, I have called the 'root' folder FG0910. In my case it happens to be in my C: drive, but of course it can be on any drive which has the space ...

c:\FG0910\AL
         \zlib-1.2.3
         \PLIB
         \SimGear\source
         \FlightGear\source
                    \data

top


OpenAL - Cross-Platform 3D Audio - http://openal.org/  

Initially I chose to try NOT to build this from source, and thought I could use the WIN32 DLLs, and headers from -
 http://www.vso.cape.com/~nhv/files/cygwin/cyg_openAL.tgz 

Silly me ... THIS DID NOT WORK! I did succeed in getting FlightGear to compile, but ran into BIG PROBLEMS when trying to run it ...

So I downloaded the full source to \AL\openal ...
The CVS commands gets the complete source - (use password "guest")
cvs -d:pserver:guest@opensource.creative.com:/usr/local/cvs-repository login
cvs -d:pserver:guest@opensource.creative.com:/usr/local/cvs-repository co openal

It has an OpenAL.dsw in the win folder, but you have to manually add the alut.dsp project to it, to build all three DLLs ... OpenAL32.dll, alut.dll, and wrap_oal.dll ... I copy the headers, al.h, alc.h, and alut.h, and the libraries, OpenAL32.lib and alut.lib to the \AL folder ... and copy the 3 DLLs to my system folder, c:\WINDOWS\System32 ...

top


zlib - A Massively Spiffy Yet Delicately Unobtrusive Compression Library - http://www.zlib.net/ 

I downloaded the zlib-1.2.3.tar.gz source from the above URL. This source contains three set of MSVC build files - zlib.[dsw|dsp], for MSVC6, and 2 x zlibbvc.[sln|vcproj] sets, for MSVC7.1 and MSVC8 ... which to use?

In the folder projects\visualc6 there is a great readme.txt, which details that the dsw/dsp files builds BOTH a DLL version, and a static library version. Since I want a 'complete' executable, that is one that does not require DLL to be distributed with the EXE file, I will concentrate on the static library versions ...

The readme.txt also warns that you will also need the assembler, ML.EXE, which they say can be obtained by downloading the latest 'Processor Pack for Visual Studio 6' ... I found it here -  http://msdn.microsoft.com/vstudio/downloads/tools/ppack/default.aspx - the ppreadme.doc which can also be downloaded states this can only be applied if you have the latest Service Pack for Visual Studio 6, which can be obtained from - http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp6/default.aspx - ... good luck with this ;=()

Since I started coding in assembler, I have already installed ml.exe 6.11 some considerable time ago, so I hope I will be ok ;=)) if I choose to use MSVC6 ... Looking in the contrib\vstudio\readme.txt I note this is a DLL only build, either by MSVC7.1 or MSVC8, as expected ... Of course, using the DLL approach, once built and installed it can also be used by other applications as well, but as stated, that means you can not pass on your FlightGear.EXE to others, without INCLUDING the DLL, and the associated LIB, if they also want to build using it ...

Already, I am starting to be 'disappointed' that SimGear dropped including the zlib-1.1.4.tar.gz from its source ... yes, the library has moved on to 1.2.3, but nothing has really 'improved' ...  SimGear only uses the services to 'unzip' FlightGear' distributed 'gz' files, so there is no 'security' risk ... anyway, after this zlib review, I choose to use the DSW/DSP files, and try to build ONLY the static libraries using MSVC7.1 ;=))

top


PLIB - STEVE'S PORTABLE GAME LIBRARY - http://plib.sourceforge.net/ 

You can choose to download the plib-1.8.4.tar.gz tar ball. Be careful when downloading this, as sometimes the XP download s/w, will change the default name to plib-1.8.4.tar.tar in the 'Save As ...' dialog ... you must ensure you save this as the original name, namely plib-1.8.4.tar.gz. You can use tar.exe (and gzip.exe) to unpack this archive, as suggested on the site ... or you can use say WinZip ...

Again, the folder in the above tar ball is plib-1.8.4 ... I usually unpack it, using the folder names, into a temporary folder, then xcopy the plib-1.8.4 folder to my above PLIB folder ... Alternatively, you can use a CVS checkout, and subsequent updates, which is what I use, then copy that CVS checkout/update to the above PLIB folder ...

The using MSVC, you can open the project plib.dsw. If you are using MSVC7.1, then you must allow it to convert all to its *.sln/*.vcproj files ... I ALWAYS check each PLIB project, namely fnt, js, net, psl, puAux, pui, pw, sg, sl, ssg, ssgAux and ul Property Pages, C++ folder, Code Generation tab, Runtime Library is set to 'Multi-threaded (/MT)' for BOTH Release and Debug configurations ... of course the Debug is 'Multi-threaded Debug (/MTd)' ... THIS IS VERY IMPORTANT ...

Note the plib project is not the same as each of the above, and I set this as the Start Up Project ... but of course, there is no real 'start-up' as this is a set of static libraries ... building under MSVC should be relatively painless, although you may note a few warnings ... the build copies the resultant static libraries, and the appropriate header files to the PLIB root ... the debug libraries have '_d' appended to their name ...

top


SimGear - Simulator Construction Tools - http://www.simgear.org/ 

Again you can choose to download the latest tar ball ... at the time of writing this it was SimGear-0.3.9.tar.gz, and unpack this using say WinZip ... but again you will have to 'fiddle' with the folder ... the base folder in the archive will be SimGear-0.3.9 ... thus you can unpack this, with folder names, to a temporary folder, than xcopy the resultant SimGear-0.3.9 folder into the above SimGear\source folder ... or, like me use a CVS checkout/update, and copy that to the above SimGear\source folder ...

There are two steps to attend to BEFORE opening MSVC ...

(i) the file in SimGear\source\src-libs, namely zlib-1.1.4.tag.gz, has to be unpacked. This is one case where I retain the full folder name, and unpack it into FG0910\SimGear\source\src-libs\zlib-1.1.4 ... you can put it where you like ;=)) but remember to adjust the relevant instructions below, accordingly ...

(ii) the file in SimGear\source\simgear called simgear_config.h.vc5, needs to be copied to, or renamed to simgear_config.h ... more recently, it appears this step has been automated through a custom step in the DSP build file ...

Now you can open MSVC, and load SimGear.dsw ... in the past this would include two other projects, namely meta-kit, and zlib, and they would both fail to load, but again the recent CVS source appears to only have the SimGear project ... if they are there, and fail, delete them, and then add the zlib.dsp project ... These two projects, SimGear and zlib are not inter-related, but BOTH must be compiled ...

Again, it is prudent to check the Property Pages of both projects, ensuring they both use the 'Multi-threaded [Debug] (/MT[d])' runtime library, and you will have to adjust the SimGear 'Additional Include Directories'. Here is the value I use -
..\..;..;SimGear;src-libs\zlib-1.1.4

You will have to adjust this if you have used any different folder structure than the one above ... Breaking them up ...
i. the '..\..' is to pass in PLIB and AL, like <plib/sg.h> and <AL/al.h>
ii. the '..' is to get at, like <simgear/compiler.h>
iii. the 'SimGear' for <simgear_config.h>
iv. the 'src-libs\zlib-1.1.4' is for zlib.h

As usual, you may see a number of warnings, like -
(a) c:\FG0910\SimGear\source\simgear\props\props.cxx(909) : warning C4018: '>=' : signed/unsigned mismatch
(b) c:\FG0910\SimGear\source\simgear\sound\sample_openal.cxx(66) : warning C4800: 'ALuint' : forcing value to bool 'true' or 'false' (performance warning)
(c) c:\FG0910\SimGear\source\simgear\nasal\string.c(214) : warning C4244: 'function' : conversion from 'double' to 'int', possible loss of data

These can usually be ignored ...

When completed you should have a set of 4 static libraries, with their approximate sizes shown in brackets -
2 Debug -
C:\FG0910\SimGear\source\Debug\SimGear.lib (~21MB)
C:\FG0910\SimGear\source\src-libs\zlib-1.1.4\Debug\zlib.lib (~200KB)
and 2 Release
C:\FG0910\SimGear\source\Release\SimGear.lib (~9MB)
C:\FG0910\SimGear\source\src-libs\zlib-1.1.4\Release\zlib.lib (~90KB)

top


FlightGear - open-source, multi-platform flight simulator - http://www.flightgear.org/ 

Again you can choose to download the archive FlightGear-0.9.9.tar.gz, unpack it using say WinZip into a FlightGear-0.9.9 folder, and copy that to the above FlightGear\source folder, or checkout/update the CVS source, and copy that.

One quick step before you load MSVC is to copy, or rename -
C:\FG0910\FlightGear\source\src\Include\config.h-msvc6.in
to config.h in the same 'Include' folder ...

Load C:\FG0910\FlightGear\source\FlightGear.dsw into MSVC, and if using later than MSVC6, allow it to convert all the files ... as usual, check both configurations are using the 'Multi-threaded [Debug] (/MT[d])' runtime library ... and you will have to fix the 'Additional Include Paths' ... If you want to build this up yourself, I usually start with a 'blank' ...

This can be quite tedious and time consuming, since every change in the 'Additional Include Paths' causes a re-build of all the previous files ... it is certainly worth finding the particular file, and do a single compile on it first, to at least make sure what you have added will work ... it takes some time to understand that it is all relative to the location of the FlightGear.DSW, now FlightGear.SLN file ...

If you have used the above folder structure exactly, then here is my 'Additional Include Paths' -
src\Include;..\..;..\..\SimGear\source;src;..\..\SimGear\source\src-libs\zlib-1.1.4;src\FDM\JSBSim

You will get literally hundreds of warnings ... perhaps the most frequent is C4101 - unreferenced local variable ... maybe this does not show up using the unix gcc compiler, without adding an option, or normally there is so much output when using the automake tools, that it is easy to overlook this 'warning' ... of course it does nothing except use a little more of the stack than would otherwise be required, so can be ignored ...

A 'strange' warning is C4800 - forcing value to bool 'true' or 'false' (performance warning) - why MS compiler writer chose to add the 'performance warning' is beyond belief ... anyway, this can also be ignored, since a 'conversion' has been supplied by the compiler ;=()

Of course warning C4018 - signed/unsigned mismatch - occurs relatively frequently. Again maybe this is not shown by the gcc compiler, since it should be cause for some concern ... but again I usually choose to ignore it ...

A more serious warning is that like -
c:\FG0910\FlightGear\source\src\AIModel\AICarrier.cxx(443) : warning C4541: 'dynamic_cast' used on polymorphic type 'ssgBase' with /GR-; unpredictable behavior may result
Again we can only hope the developer is 'correct' in the cast ;=/

And there are usually quite a few of the form -
c:\FG0910\FlightGear\source\src\FDM\YASim\Turbulence.cpp(156) : warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data
c:\FG0910\FlightGear\source\src\FDM\YASim\Rotorblade.cpp(66) : warning C4305: '=' : truncation from 'double' to 'float'

It is assumed the developer 'knows', and understands this, and this is exactly what he/she wanted to do ...

There may be sundry others, like -
c:\FG0910\FlightGear\source\src\FDM\LaRCsim\ls_model.c(182) : warning C4013: 'c172_init' undefined; assuming extern returning int
all of which I choose to IGNORE, especially on this first compile and links, since I get thousands of link errors, since I have not yet address the linking with the static libraries, and other system libraries ... This first run produced an output -

FlightGear - 4262 error(s), 301 warning(s)

Adding the static libraries, and a path to them can again be a tedious process ... you can look at each unresolved external, and try to find the appropriate static or system library ... we know we must at least add the PLIB items, SimGear, and zlib ...

Adding -
wsock32.lib SimGear.lib fnt_d.lib js_d.lib net_d.lib psl_d.lib puAux_d.lib pui_d.lib pw_d.lib sg_d.lib sl_d.lib ssgAux_d.lib ssg_d.lib ul_d.lib zlib.lib

with 'Additional Library Paths' of -
..\..\SimGear\source\Debug, ..\..\PLIB, ..\..\SimGear\source\src-libs\zlib-1.1.4\Debug

immediately reduced the massive number of errors to -
fatal error LNK1120: 24 unresolved externals
and these 24 appear to all be OpenAL items ...

So I add OpenAl32.lib and alut.lib to the above ... I had copied these, after building, to my AL folder, and thus added the path to them, namely ..\..\AL
I am rewarded with SUCCESS - the MSVC output now being -

Linking...
Build log was saved at "file://c:\Fg0910\FlightGear\source\Debug\BuildLog.htm"
FlightGear - 0 error(s), 0 warning(s)
---------------------- Done ----------------------
    Build: 1 succeeded, 0 failed, 0 skipped

Now to try running it ... with a simple command line -

--fg-root=c:\FG0910\FlightGear\data --aircraft=ufo --fdm=ufo --log-level=debug

and it ran ...

... WHAT A FANTASTIC FLIGHT SIMULATOR PROGRAM THIS IS! ...

top


More on OpenAL:

Knowing the windows system, I put the DLL in one of my PATH environment variables, and put the LIBRARIES in c:\FG0910\AL ... hoping that would work, but you LEARN new things every day ... part of the OpenAL libraries SEARCH for the wrap_oal.dll, but it ONLY searches in certain places - like, in the comment in alc.cpp says -
    // Directory[0] is the current directory
    // Directory[1] is the current app directory
    // Directory[2] is the system directory.

SO, you either have to put the wrap_oal.dll in the 'current directory', or the 'application directory', OR the 'system directory' - like c:\WINDOWS\System32 -

OR, I have to improve the 'search service' -
HINSTANCE FindDllWithMatchingSpecifier(TCHAR* dllSearchPattern, char* specifier, bool partialName = false, char *actualName = NULL)
to LOOK HARDER ... done ... tell them about it ...
http://opensource.creative.com/mailman/listinfo/openal-devel
The archives
http://opensource.creative.com/pipermail/openal-devel/ 

FOR A LATER MSVC7 BUILD, OF THE CVS SOURCE, WITH OSG, SEE fgfs-036.htm

EOF - fgfs-022.htm, from fg-36.doc - 23 March 2006.

index

Valid HTML 4.01 Transitional