Difference between revisions of "Compiling using GCC"

From OdaWiki
(Cygwin)
m (FreeBSD)
 
(17 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Note: If you intend to build the client, you'll need the current version of SDL and SDL_mixer development libraries installed.
+
GCC is the official GNU C Compiler which is bundled with many Unix and Linux distributions.  This article assumes that you are planning to build Odamex at the command line.  If you are using an IDE that uses GCC as its compiler, please refer to the IDE's documentation in this wiki on how to compile Odamex.
  
== GNU/Linux ==
 
  
=== Get the source ===
+
== Compiling in a nutshell ==
You can either download a stable source package, or risk using the bleeding edge svn code.
+
Compiling using GCC is simple.  Simply go to the root directory of the branch that you want to compile and type:
  
==== Download ====
+
<pre>make</pre>
Download the [http://odamex.net/ latest source]
+
Untar the archive somewhere:
+
  
<pre>
+
This will compile the client, the server and the master, one after another. If you want to compile them one at a time, simply use one of the following commands:
tar -xjf odamex_build.tar.bz2
+
cd odamex_build
+
</pre>
+
  
==== SVN ====
+
<pre>make client
Get a dev build using (must have [[svn|subversion]] installed!):
+
make server
 +
make master</pre>
  
<pre>
+
That's it!
svn co svn://odamex.net
+
</pre>
+
  
=== Build ===
+
== Compiling the Launcher ==
 +
Assuming you have the WX libraries installed, and you are in the trunk directory of SVN (or the root source directory), the following should be enough to compile the Launcher:
  
In the source directory, use the make command:
+
<pre>cd odalaunch
 +
wx-config --prefix        # find out what to pass to the makefile as WXBASE
 +
make WXBASE=/usr          # replace with appropriate value</pre>
  
<pre>
+
This should give you a working launcher.  The Makefile makes some assumptions about the whereabouts of WX, and if these assumptions are wrong, they need to be configured via commandline as WXBASE was above.  Here is a list of the default settings:
make
+
</pre>
+
  
Binaries should appear in the bin dir after a successful compile: odamex, odasrv, odamaster
+
<pre>WXBASE = /usr/local
 +
WXCONFIG = $(WXBASE)/bin/wx-config
 +
WXRC = $(WXBASE)/bin/wxrc
 +
CFLAGS = $(shell $(WXCONFIG) --cflags) -g
 +
LFLAGS = $(shell $(WXCONFIG) --libs) -g</pre>
  
You can run "make server" or "make client" to only build the module you want:
+
== Platform-specific notes ==
 +
===Package Based Distributions===
 +
Be sure to install the development packages for SDL and other libraries under distributions such as Fedora and Ubuntu.  Odamex will not compile unless they are present.
  
<pre>
+
===FreeBSD===
make server
+
FreeBSD has their own version of make, which is not compatable with Odamex.  In order to compile under FreeBSD, you must install gmake from the ports collection:
make client
+
*'''GNU Make''':  [[http://cvsweb.freebsd.org/ports/devel/gmake gmake-3.80_2]]
make launcher
+
Then, substitue '''gmake''' for '''make''', respectively.
</pre>
+
  
== FreeBSD ==
 
  
To compile Odamex on FreeBSD, you must have the following ports installed, above and beyond the usual suspects:
+
When compiling the launcher on FreeBSD, you must also edit the Makefile so that it points to the correct wx binaries.  First, make sure you have the x11-toolkits/wxgtk28 port installed. (Odamex requires 2.8. 2.6 and 2.4 will not work.) Then, edit the makefile, changing the lines:
*'''GNU Make''':  [[http://cvsweb.freebsd.org/ports/devel/gmake gmake-3.80_2]]
+
*'''SDL 1.2.9''':  [[http://cvsweb.freebsd.org/ports/devel/sdl12 sdl-1.2.9_2,2]]
+
*'''SDL_Mixer 1.2.6''': [[http://cvsweb.freebsd.org/ports/audio/sdl_mixer sdl_mixer-1.2.6_2]]
+
  
In addition, if you want to compile the absolute latest cutting edge version of Odamex, you will also need:
 
*'''Subversion''':  [[http://cvsweb.freebsd.org/ports/devel/subversion subversion-1.3.0_4 ]]
 
  
Once those ports are installed, you can simply untar or grab the latest source through subversion into its own directory, switch to the trunk subdirectory, and simply type '''gmake'''.  If you only want to compile the client or only compile the server, simply type '''gmake client''' or '''gmake server''' respectively.
+
WXCONFIG = wx-config
  
Odamex can be downloaded and built in cygwin!
+
WXRC = wxrc
  
== Cygwin ==
 
  
[[Image:cygwin.png|none|200x100px|Screenshot of Odamex in Cygwin]]
+
to:
  
=== Cygwin packages ===
 
  
You will first need to install the following [http://www.cygwin.org Cygwin] packages in addition to the default ones:
+
WXCONFIG = wxgtk2-2.8-config
  
* make
+
WXRC = wxrc-gtk2-2.8
* gcc
+
* subversion (only if you intend to use [[svn]] within cygwin)
+
  
=== SDL patches ===
 
  
Odamex depends on SDL and SDL_mixer. You will need to download the current windows development libraries from the SDL site (VC6 development libraries work fine for this). You'll need to extract the libraries and edit SDL_LOCATION and SDL_MIXER_LOCATION in the Odamex Makefile to point there.
+
After that, running "gmake" in the odalaunch/ directory will build the launcher.  Typing "gmake install" (as root) in the odamex source directory will then install the launcher on the system.
  
 +
===Cygwin===
 
Unfortunately, SDL does not always play ball with cygwin's headers. The biggest offender has been a conflict between <SDL_config_minimal.h> and <stdint.h>. You may need to edit the following two lines in <SDL_config_minimal.h>:
 
Unfortunately, SDL does not always play ball with cygwin's headers. The biggest offender has been a conflict between <SDL_config_minimal.h> and <stdint.h>. You may need to edit the following two lines in <SDL_config_minimal.h>:
  
Line 79: Line 68:
 
* typedef signed long int int32_t;
 
* typedef signed long int int32_t;
 
* typedef unsigned long int uint32_t;
 
* typedef unsigned long int uint32_t;
 +
 +
Also there is one extra step you have to do before compiling.  You must edit the makefile in the root of the branch you want to compile.  The two things you must change are SDL_LOCATION and SDL_MIXER_LOCATION, and you have to modify these two lines to point to the directories where you extracted your SDL and SDL_Mixer development libraries, respectively.

Latest revision as of 02:41, 5 August 2008

GCC is the official GNU C Compiler which is bundled with many Unix and Linux distributions. This article assumes that you are planning to build Odamex at the command line. If you are using an IDE that uses GCC as its compiler, please refer to the IDE's documentation in this wiki on how to compile Odamex.


Compiling in a nutshell

Compiling using GCC is simple. Simply go to the root directory of the branch that you want to compile and type:

make

This will compile the client, the server and the master, one after another. If you want to compile them one at a time, simply use one of the following commands:

make client
make server
make master

That's it!

Compiling the Launcher

Assuming you have the WX libraries installed, and you are in the trunk directory of SVN (or the root source directory), the following should be enough to compile the Launcher:

cd odalaunch
wx-config --prefix        # find out what to pass to the makefile as WXBASE
make WXBASE=/usr          # replace with appropriate value

This should give you a working launcher. The Makefile makes some assumptions about the whereabouts of WX, and if these assumptions are wrong, they need to be configured via commandline as WXBASE was above. Here is a list of the default settings:

WXBASE = /usr/local
WXCONFIG = $(WXBASE)/bin/wx-config
WXRC = $(WXBASE)/bin/wxrc
CFLAGS = $(shell $(WXCONFIG) --cflags) -g
LFLAGS = $(shell $(WXCONFIG) --libs) -g

Platform-specific notes

Package Based Distributions

Be sure to install the development packages for SDL and other libraries under distributions such as Fedora and Ubuntu. Odamex will not compile unless they are present.

FreeBSD

FreeBSD has their own version of make, which is not compatable with Odamex. In order to compile under FreeBSD, you must install gmake from the ports collection:

Then, substitue gmake for make, respectively.


When compiling the launcher on FreeBSD, you must also edit the Makefile so that it points to the correct wx binaries. First, make sure you have the x11-toolkits/wxgtk28 port installed. (Odamex requires 2.8. 2.6 and 2.4 will not work.) Then, edit the makefile, changing the lines:


WXCONFIG = wx-config

WXRC = wxrc


to:


WXCONFIG = wxgtk2-2.8-config

WXRC = wxrc-gtk2-2.8


After that, running "gmake" in the odalaunch/ directory will build the launcher. Typing "gmake install" (as root) in the odamex source directory will then install the launcher on the system.

Cygwin

Unfortunately, SDL does not always play ball with cygwin's headers. The biggest offender has been a conflict between <SDL_config_minimal.h> and <stdint.h>. You may need to edit the following two lines in <SDL_config_minimal.h>:

  • typedef signed int int32_t;
  • typedef unsigned int uint32_t;

To read:

  • typedef signed long int int32_t;
  • typedef unsigned long int uint32_t;

Also there is one extra step you have to do before compiling. You must edit the makefile in the root of the branch you want to compile. The two things you must change are SDL_LOCATION and SDL_MIXER_LOCATION, and you have to modify these two lines to point to the directories where you extracted your SDL and SDL_Mixer development libraries, respectively.