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.
Contents
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 > from the menu.
Select under the node in the list of on the left of this dialog.
Select 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 check box.
Once you have created the solution, the top node in the Solution Explorer should now show . The project should also be shown directly below this with three empty nodes: , , and .
Step 2. Import the Source and Header Files
Right-click on the node and select > 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 text box and press Enter. This will filter the files to only header files. Select all the files using Ctrl+A and then click .
Right-click on the node and select > 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 .
Step 3. Set the Project Properties
Select the project in the Solution Explorer and click from the menu.
Set the active configuration to in the combo box on the top left of this dialog and then set the following properties:
- =
- =
- = ..\..\..\;..\..\..\..\galib247
- = _CRT_SECURE_NO_DEPRECATE
- =
- =
Note: the 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 from the menu and change the configuration to in the combo box on the top left of the dialog.
Select from the 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 functionsstrcpyandsprintfare 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.