Difference between revisions of "Compiling the Source Code"

From Open Surge Engine Wiki
Jump to: navigation, search
Line 22: Line 22:
 
=== Dependencies ===
 
=== Dependencies ===
  
 
+
In order for the compiler to know where to get the liraries, we need to add two variables to your system; right-click on "My Computer", select "Properties", then "Advanced System Settings", and then "Environment Variables".
Now we should download all the dependencies. It is recommendable that you extract the files in an easy to read folder structure. For example, on a main folder called "src", extract each dependency to its separate folder.
+
 
+
Let's go to http://alleg.sourceforge.net/download.html and download Allegro 4.4.2.. Extract the contents of the file into the folder where we are going to keep the dependencies.
+
 
+
It is now recommended that we compile Allegro. To avoid any errors, we should go to the folder where Allegro was extracted, and delete the CMakeCache.txt file before compiling.
+
 
+
It may also be needed to add two variables to your system, so we are going to right-click on "My Computer", select "Properties", then "Advanced System Settings", and then "Environment Variables".
+
  
 
Now, in the lower box, we select the variable called "Path" and then click "Edit". If it doesn't exist, we should create it.
 
Now, in the lower box, we select the variable called "Path" and then click "Edit". If it doesn't exist, we should create it.
Line 38: Line 31:
  
 
If you're creating it, ignore the ; at the beginning and paste the rest. Give OK to all open dialog boxes.
 
If you're creating it, ignore the ; at the beginning and paste the rest. Give OK to all open dialog boxes.
 +
 +
== Quick and Easy Way (experimental) ==
 +
 +
https://dl.dropboxusercontent.com/u/20216605/Open%20Surge%20contents/Compilation%20Cookbook/MinGW.zip
 +
 +
Simply download and unzip to your MingW folder. and skip the old school way and go to "Compiling Open Surge: Windows - MinGW". Only go through it if you really know what to do when to get compilation errors.
 +
 +
== Old School Way==
 +
 +
Now we should download all the dependencies. It is recommendable that you extract the files in an easy to read folder structure. For example, on a main folder called "src", extract each dependency to its separate folder.
 +
 +
Let's go to http://alleg.sourceforge.net/download.html and download Allegro 4.4.2.. Extract the contents of the file into the folder where we are going to keep the dependencies.
 +
 +
It is now recommended that we compile Allegro. To avoid any errors, we should go to the folder where Allegro was extracted, and delete the CMakeCache.txt file before compiling.
  
 
Now it's time to run CMake GUI.
 
Now it's time to run CMake GUI.

Revision as of 01:05, 5 January 2014

Stub
This article is a STUB. It's not complete and it's not guaranteed that the information is 100% correct


Compiling the Source Code

At some point you may want to compile the game/engine on your own, mostly if you are modifying the sources.

From here on, when GAMEDIR is mentioned, it means only the directory where you unpacked the game. GAMEDIR stores, among other things, a readme.html page and a file called CMakeLists.txt. In reality your GAMEDIR may be called anything else other than that.


Preparing the compilation environment: Windows

We will first need two programs:

Download and install both of them, the latest versions. It will be better if you install MingW in your C: disk, under C:\MingW.

Dependencies

In order for the compiler to know where to get the liraries, we need to add two variables to your system; right-click on "My Computer", select "Properties", then "Advanced System Settings", and then "Environment Variables".

Now, in the lower box, we select the variable called "Path" and then click "Edit". If it doesn't exist, we should create it.

If it exists, add this at the end:

;C:\MinGW\bin;C:\MinGW\lib

If you're creating it, ignore the ; at the beginning and paste the rest. Give OK to all open dialog boxes.

Quick and Easy Way (experimental)

https://dl.dropboxusercontent.com/u/20216605/Open%20Surge%20contents/Compilation%20Cookbook/MinGW.zip

Simply download and unzip to your MingW folder. and skip the old school way and go to "Compiling Open Surge: Windows - MinGW". Only go through it if you really know what to do when to get compilation errors.

Old School Way

Now we should download all the dependencies. It is recommendable that you extract the files in an easy to read folder structure. For example, on a main folder called "src", extract each dependency to its separate folder.

Let's go to http://alleg.sourceforge.net/download.html and download Allegro 4.4.2.. Extract the contents of the file into the folder where we are going to keep the dependencies.

It is now recommended that we compile Allegro. To avoid any errors, we should go to the folder where Allegro was extracted, and delete the CMakeCache.txt file before compiling.

Now it's time to run CMake GUI.

Use this image as a reference on how to configure

Cmake.jpg


Now we need

Make sure you follow the Generic installation instructions, ONLY IF YOU GET IT FROM THERE. If you read on, you can have it a little easier.

For ease of access, here are the download links:

http://opensnc.sourceforge.net/alfont/mirror/AlFont209.rar (Original Alfont)

https://dl.dropboxusercontent.com/u/20216605/Alfont%20Mod/alfont.c (Modified Alfont, conveniently prepared for download).

Now, after downloading and extracting the Original Alfont, replace alfont/src/alfont.c with the modified alfont.c you just downloaded.

Now you should

  • Compile Alfont.

Follow the compilation process described in alfont/README.txt.

After running make, copy alfont/lib/mingw32/libalfont.a and alfont/include/* to the MingW directories, normally C:/MingW/lib , and C:/MingW/include .

You should now be ready for the final step.

Compiling Open Surge: Windows - MinGW

When using MinGW, make sure both lib\ and bin\ folders are listed on your PATH. If MinGW is installed on C:\MinGW\, simply open a Command Prompt (cmd) and type:

set PATH=%PATH%;C:\MinGW\bin;C:\MinGW\lib

On the same Command Prompt, please go to GAMEDIR and run the following commands:


cmake -G "MinGW Makefiles" .

mingw32-make


Note that little '.' at the end of the first command. If everything works well, opensurge.exe will be in GAMEDIR.


Additional Help

To compile anything quick and easy with a double click, drop this batch file in a folder containing source code:

https://dl.dropboxusercontent.com/u/20216605/Open%20Surge%20contents/compile.bat

Simply double click to run and compile. Please note that if there is an error you should use the command line to see for yourself, because the window will close when the batch is done.