Chapter 3. Compiling FEAR

Table of Contents

3.1. Full Compilation
3.2. Animats
3.3. Modules
3.4. Platform
3.4.1. Quake 2
3.5. C++ Framework

For speed and simplicity, FEAR currently uses hard linking and DLL (dynamic library) loading to connect the different C++ modules together. In C++, there are no cross-compiler standards for binary compatibility; the ABI (Application Binary Interface) changes from one vendor to another, one compiler version to another and even one build variant to another. This means that you must make sure to build everything with the same compiler, or make sure to use pre-compiled versions that match with your compiler. By default, the libraries should build in debug mode — which is ideal for most research and education projects (that current versions of FEAR are intended for).

The previous build phase can handle compilation thanks to SCons. This chapter is an alternative way to compile FEAR using Visual Studio only. The build phase also produces workspaces and project files for each part of FEAR. These are also present in the SDK distribution, which can be downloaded on Sourceforge project page.

3.1. Full Compilation

In most distributions, there is a workspace that has all the project files included. This can be found in the root directory of the distribution, usually under the name fear/FEAR.[dsw,sln]. Use the .dsw file if you have Visual C++ 6.0, and the .sln if you own Visual Studio 7.0.

The best way to build everything is to select the Build menu, and select Batch Build. From there, select all the Debug configurations, and select Rebuild All. This will start the build process and display the output in the console.

--- Build started: Configuration: Debug ---






Generating Code...

Creating library...

C++ Framework - 0 error(s), 0 warning(s)

If you run into trouble, it's most likely that the Boost library was not setup in the fear/boost directory. See the previous chapter for more information.

Read on to find out about the different projects that were compiled, particularly what happens to the output files.

3.2. Animats

The demonstration animats are located in subdirectories of fear/demos/animats. Each of them have their own project file, usually named NickBrain.[dsp,vcproj]. To build the animat, simply launch the appropriate project and Visual Studio will prompt you to create a workspace. Then click on the Build menu, and start the compilation.

By default, the binaries will be placed in a subdirectory of fear/build/variant/demos/. The important file is a dynamic library (DLL) that contains the code for this animat's brain. It's usually named NickBrain-?.dll, where ? is the version of Visual Studio.

As a post build step, the DLL brain file is automatically renamed and copied to the FEAR platform. In this case, it's a subdirectory of Quake 2. You'll notice the message in the console after the operation has been performed: 1 file(s) copied. You need to setup the %QUAKE2% environment variable for this to work, as described in this section from the next chapter.

This copying is done to simplify the development phase by avoiding having to copy files manually. Note that the files cannot be build directly into the subdirectory of Quake 2 because Visual Studio cannot know about the location of the FEAR platform in advance (or in the project settings).

3.3. Modules

The modules are handled just like the animats. In fact, animat brains are specific kinds of modules. The modules are stored in subdirectories of fear/modules/, each with their own project files named Module.[dsp,vcproj] (depending on the name of the module). These can be built in the usual way.

The binaries are stored as DLL files in fear/build/variant/modules/, with the same name as the module — but with the version of Visual Studio as a suffix. The build post-process operation will rename and copy the file to the appropriate subdirectory of Quake 2 for convenience.

3.4. Platform

The platform is (part of) an executable that runs the simulation, for example a Quake 2 modification of the logic as a file called gamex86.dll. The platform generally depends on the framework library, as discussed in the next section.


You do not normally need to build the FEAR platform; a default binary is provided for most standard compilers (under windows). Read this section if you intend to modify the backend interfaces, or use an unsupported compiler.

3.4.1. Quake 2

The default platform provided with FEAR is Quake 2. There is a workspace called game.[dsp,vcproj], which can be found in the subdirectory fear/platform/quake2/. This will build out of the box with the appropriate version of Visual Studio.

Again, the DLL file is copied automatically to the target location as a post-build operation. This is done according to the %QUAKE2% environment variable, which is discussed more in the next chapter.

3.5. C++ Framework

The C++ framework also has its own workspace file named Framework.[dsp,vcproj], which can be found in the directory fear/framework/C++/. This should build equally easily straight off the bat, given that the Boost library is installed correctly.

The framework is a static library named FEAR?.lib. As usual, The version of Visual Studio is used as the suffix to prevent clashes. The library can be found in the fear/build/variant/ directory. It is found by default by all the other projects that depend on it.