Compiling libGE Using Microsoft Visual C++

libGE is a software development library for Grammatical Evolution, a method of automatically generating computer programs in any language. This page gives a brief summary of the steps required to compile the libGE library using the Microsoft Visual C++ development platform.

Prerequisites

libGE version 0.26
Available to download from the libGE website.
GAlib version 2.4.7
Available for download from the GAlib website. For a tutorial on compiling GAlib in Microsoft Visual C++, see this page.
Microsoft Visual C++
The Express edition is available to download for free from the Microsoft website. This tutorial was written for the 2005 version but it should be applicable to the current 2008 edition. It should also be applicable to the versions of Visual C++ that are shipped with the Express, Standard, and Professional versions of Microsoft Visual Studio.

Step 1. Create a New Solution and Project

Open Microsoft Visual C++ and select New > Project from the File menu.

Select General under the Visual C++ node in the list of Project types on the left of this dialog.

Select Empty Project in the templates panel on the right.

Enter a name for the project. In this example, the project name is ge.

Enter or browse to a location for the project. This example assumes the location to be in the directory projects under the libGE distribution directory e.g. C:\libGE\projects\.

Enter a name for the solution e.g. vcpp2005 and check the Create directory for solution check box.

Once you have created the solution, the top node in the Solution Explorer should now show Solution 'vcpp2005' (1 project). The project ge should also be shown directly below this with three empty nodes: Header Files, Resource Files, and Source Files.

Step 2. Import the Source and Header Files

Right-click on the Header Files node and select Add > Existing Item... from the pop-up menu. In the dialog box that opens, browse to the src directory within the libGE distribution on your system. Enter *.h into the File name: text box and press Enter. This will filter the files to only header files. Select all the files using Ctrl+A and then click Add.

Right-click on the Source Files node and select Add > Existing Item... from the pop-up menu. In the dialog box that opens, browse to the src directory within the libGE distribution on your system. Enter *.cpp and press Enter to filter the files to only source files. Select all the files using Ctrl+A and then click Add.

Step 3. Set the Project Properties

Select the ge project in the Solution Explorer and click Properties from the Project menu.

Set the active configuration to All Configurations in the combo box on the top left of this dialog and then set the following properties:

General
Configuration Type = Static Library (.lib)
Common Language Runtime Support = No Common Language Runtime Support
C/C++ > General
Additional Include Directories = ..\..\..\;..\..\..\..\galib247
C/C++ > Preprocessor
Preprocessor Definitions = _CRT_SECURE_NO_DEPRECATE
Precompiled Headers
Create/Use Precompiled Headers = Not Using Precompiled Headers
Advanced
Compile As = Compile As C++ Code (/TP)

Note: the Additional Include Directories value above assumes that the GAlib distribution is in the same parent directory as the libGE distribution e.g. C:\galib247 and C:\libGE-0.26.

Step 4. Build the Project

The default build configuration in Visual C++ has debugging enabled. If you don't want to debug the libGE code, select Configuration Manager... from the Build menu and change the configuration to Release in the active solution configuration combo box on the top left of the dialog.

Select Build ge from the Build menu to build the project.

Additional Issues

You may experience some of the following issues when trying to compile the library. I have included possible solutions where possible.

Error: Genotype.cpp(185) ostream string operator error

Solution: add #include <ostream>.

Error: Genotype.h(13), Phenotype.h(39), and Mapper.h(14)
std namespace not declared

Solution: add the #using namespace std; directive after all #include's in these headers.

Error: GE_ILLIGALSGA.cpp(171) and CFGrammar.cpp(102)
expected constant expression

Solution: allocate the memory for the arrays dynamically (you can't use a const variable when declaring a a stack-based array either).

Warning: The functions strcpy and sprintf are deprecated

Solution: set the preprocessor flag _CRT_SECURE_NO_DEPRECATE to disable this warning.

Warning: Phenotype.cpp(99) the function strdup is deprecated

Solution: use the function _strdup to get around this.

The libGE website
The Biocomputing and Developmental Systems Group website
The Grammatical Evolution website