Building the C4 Engine
From C4 Engine Wiki
Contents |
Development Environment
The C4 Engine ships with project files for Microsoft Visual Studio and Apple's Xcode environment. Both of these developer tools are available in versions that can be downloaded for free, from the following Microsoft and Apple developer web sites:
Microsoft Visual C++ 2008 Express Edition
If you are building under Windows, make sure that you also have the August 2009 version (or later) of the DirectX SDK installed. The SDK can be downloaded from this MSDN web site:
Setting up the SDKs in Visual Studio
So that Visual C++ can find the correct header files and libraries, you may need to set a couple of directories before compiling. Select Options from the Tools menu. There is an item in the list on the left side of the window named “Projects and Solutions”. Click on this item and then click on the sub-item named “VC++ Directories”. There will then be a popup menu in the upper right corner of the window entitled “Show directories for:”.
Select “Include files” from the popup menu and add the path to the DirectX SDK include directory, which should look like the following.
C:\Program Files\Microsoft DirectX SDK (August 2009)\Include
Next, select “Library files” from the popup menu and add the path to the DirectX SDK library directory, which should look like the following.
C:\Program Files\Microsoft DirectX SDK (August 2009)\Lib\x86
Note that if you install the DirectX SDK after installing Visual C++ 2008, then these directories should be set up automatically.
Building under Windows
After a fresh install of C4, the project files for Visual Studio are located at the following place.
VisualStudio/C4/C4.sln
After opening the project file in Visual Studio, select “Build Solution” from the Build menu to build the engine. This will cause several binaries to be built: C4.exe, Game.dll, SimpleBall.dll, SimpleChar.dll, and a bunch of DLLs that get stored in the Plugins directory.
Debugging under Windows
To run C4 in debug mode from Visual Studio, make sure that the Working Directory is set to “..\..\..”. This setting can be found by right-clicking on the Engine project in the Solution Explorer, selecting Properties, and finally going to the Debugging pane as shown below. If you don't set this directory, a dialog will appear when you run C4 telling you to do so.
Building under Mac OS X
The Xcode project file is contained in the Xcode.zip file that's included with the C4 Engine distribution. This ZIP file should be extracted on a Mac so that the correct bundle structure is preserved. Be sure to extract the Xcode folder into the top-level C4 folder. The project file for Xcode 3 is located at the following location within the C4 folder.
Xcode/C4/C4.xcodeproj
After opening the project file in Xcode, change the Active Target to “Build All”. Then, either select Build from the Build menu or click the Build icon. The built product is called C4.app and is placed at the top level of the C4 folder. The game modules (Game.bundle, SimpleBall.bundle, and SimpleChar.bundle) and tool modules are stored inside the C4.app bundle in the C4.app/Contents/Resources/ folder. The engine can be run by double-clicking on the C4.app application bundle.
You can switch between the Debug and Optimized builds of the engine by selecting a configuration from the “Set Active Build Configuration” submenu of the Project menu. (There is also a popup menu in the Build Results window where this can be selected.)
Link errors under 10.6
If you are experiencing link errors when build in the newest version of Xcode, then you need to change the compiler version to GCC 4.0 by following these steps:
- In Xcode, right-click (or Ctrl-click) on the C4 project at the top of the Groups & Files list, and then select Get Info from the menu that appears.
- When the info window appears, go to the Build tab if you're not already there.
- There's a Configuration popup menu in the upper-left corner of the window. Set it to All Configurations.
- Find the Compiler Version section in the list of settings, and change the C/C++ Compiler Version to "GCC 4.0".
- Close the info window and recompile.
The default compiler, GCC 4.2, contains a rewrite of the "visibility" code that handles symbol export for the linker, and it's full of bugs.

