Difference between revisions of "Guide to FS Open on Linux"

From FreeSpace Wiki
Jump to: navigation, search
m (clarification)
m (clarification)
Line 19: Line 19:
 
'''but I have no knowlage on how these work, so if you do, please enlighten us.'''
 
'''but I have no knowlage on how these work, so if you do, please enlighten us.'''
  
== Installing Development Libs ==
+
== Installing nessesary development libraries ==
 
You will also need OpenAL, libvorbis, OpenGL (most likely provided with your videocard driver), and LUA development packages (you don't need LUA if you don't need LUA scripting enabled, it wont breake the compile if it can't find it). And ofcourse the GCC compiler and required make tools.
 
You will also need OpenAL, libvorbis, OpenGL (most likely provided with your videocard driver), and LUA development packages (you don't need LUA if you don't need LUA scripting enabled, it wont breake the compile if it can't find it). And ofcourse the GCC compiler and required make tools.
 
<br><br>
 
<br><br>

Revision as of 14:54, 3 March 2006

This HOWTO was written by ni1s to help Freespace fans get the latest bleeding-edge version of fs2_open from CVS, and also includes an introduction to configuring and running fs2_open provided by Spectre-7.

This tutorial will provide you with an executable, but in order to play the game you also need the game data. Freespace 2 game data is available from a number of sources, including http://www.the-underdogs.org/ Please refer to Getting Started for more information about fs2_open and what is required to play.

WARNING! Compling from CVS will let you play with the most recent features and BUGS! Yes, BUGS, compile errors, strange game behavior and/or angry monkeys attacking you. Murphy's Law is very much in effect!

Installing CVS

CVS stands for Concurrent Versions System and is a version control system used to record the changes in documents, such as source files. Developers use CVS so they can easily share their code changes among other developers. You will need this tool to download ("checkout" in CVS termology) fs2_open from the CVS server.

Use your package tool supplied by your distribution to download and install CVS.

Debian users want to:

apt-get install cvs

Gentoo users want to:

emerge cvs

NOTE: Radhat, Mandrake,Slackware and all the other distros should go here too, but I have no knowlage on how these work, so if you do, please enlighten us.

Installing nessesary development libraries

You will also need OpenAL, libvorbis, OpenGL (most likely provided with your videocard driver), and LUA development packages (you don't need LUA if you don't need LUA scripting enabled, it wont breake the compile if it can't find it). And ofcourse the GCC compiler and required make tools.

Debian users want to:

apt-get install libopenal-dev libvorbis-dev build-essential automake1.9 autoconf

NOTE: The build-essential meta package installs GCC4. This should work, but if you feel safer with GCC 3.4(gcc-3.4), add it to the apt-get line above.
Gentoo users want to:

emerge openal libvorbis

NOTE: Radhat, Mandrake,Slackware and all the other distros should go here too, but I have no knowlage on how these work, so if you do, please enlighten us.

Before you begin, make sure you are situated in a a directory where you have write permissons. Your /home/user/ directory is pretty much a sure bet. I recommend that you create a permanent home/user/dev directory from which you run the CVS command, this way CVS will only update the files changed the next time you download the source and it's always nice to hav things organized.

Using the source

Downloading

Now get the source. Run from a terminal:

cvs -d:pserver:anonymous:[email protected]:/home/fs2source/cvsroot login

and then

cvs -z3 -d:pserver:[email protected]:/home/fs2source/cvsroot co fs2_open

The first cvs command tells the CVS tool to first use a password file for authentication (pserver), that you are user "anonymous" with the password "anonymous" who wants to access warpcore.org's CVS repository "/home/fs2source/cvsroot" and login. The second command tells the CVS server on which we are now connected to that we want to checkout (co) the fs2_open module.

CVS Checkout and Update Script

The code on CVS is in a constant state of change, and bugs that exist one day may be gone the next. Because of this, you'll want to occasionally update to a newer version and recompile. Running those cvs commands will fast grow to be a pain, so this little script was created to make your life abit easier. This script will checkout fs2_open if it can't find a fs2_open directory and update fs2_open, if it finds it. The script will run until a successfull checkout or update has been achieved.

#!/bin/bash
# CVS Checkout and Update Script for fs2_open
CVS_LINE="cvs -d:pserver:anonymous:[email protected]:/home/fs2source/cvsroot"
if [ "$UID" = 0 ]; then
	echo "You are root. If this is a checkout, all files \
	will be created with root as the owner."
	sleep 3
fi  
if [ -e ./fs2_open ]; then
	echo "Found fs2_open, We are updating an old checkout.."
CVS_ATTEMPT=0
until [  $CVS_ATTEMPT = 1 ]; do
	$CVS_LINE login && \
	$CVS_LINE update fs2_open && \
	let CVS_ATTEMPT=1
done
else
	echo "No fs2_open found, This is a new checkout."
CVS_ATTEMPT=0
until [  $CVS_ATTEMPT = 1 ]; do
	$CVS_LINE login && \
	$CVS_LINE co fs2_open && \
	let CVS_ATTEMPT=1
done
fi

Building

In the directory you ran the CVS command from, a new directory will appear, namely fs2_open. From that fs2_open directory run in a terminal:

./autogen.sh

autogen.sh is a script that will generate the required makefiles. You will see alot of "checking for this" and "checking for that", this is actually the "configure" script (which can be run with ./configure if you need to change the options) examining and configuring fs2_open for your system.
It is possible to give autogen.sh configure options aswell, autogen.sh will pass them along to configure.

Now run:

make 

Sit back and enjoy gcc work its magic.

GL Compile Errors

On some Linux distributions (Slackware for instance), compiling fails because a GL related library doesn't have a link in the /usr/lib directory. If the compile fails because it can't find -lGLU, here are two ways to fix it:

As Root

If you have root access to the system, you can create a link to the library in question with just a little bit of command line magic. Go to a console and enter:

ln -s /usr/X11R6/lib/libGLU.so /usr/lib/libGLU.so

After that, you can run make again and it should finish compiling.

As a Non-Root user

You don't have root access? Never fear, we can still fix the problem. It'll just be a tad more difficult.

Navigate to the fs2_open/code directory and locate a file named Makefile (not Makefile.rm or Makefile.in or Makefile.anything). Open it in your favorite text editor and make the following changes.

Find this line (line 457 in mine):

FS2_LDFLAGS =  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lGLU -lopenal -logg -lvorbis -lvorbisfile

And replace it with this:

FS2_LDFLAGS =  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lopenal -logg -lvorbis -lvorbisfile -L/usr/X11R6/lib -lGLU 


Also find this one (line 565 in mine):

AM_LDFLAGS =  -g  -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lGLU -lopenal -logg -lvorbis -lvorbisfile

And replace it with this:

AM_LDFLAGS =  -g -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lGL -lopenal -logg -lvorbis -lvorbisfile -L/usr/X11R6/lib -lGLU

Then run make from the fs2_open directory, and watch the magic happen.

Optimizing fs2_open

Optimizing fs2_open might have little or no effect, or improve performace greatly, I honestly have no clue.
A note of caution, if you are compiling a debug build, don't use the -fomit-frame-pointer CFLAG, it will make debugging impossible.
You can specify your compiler flags with the configure script, se below.

./configure CFLAGS="<your desired flags>"

If you got a Athlon-XP and want to play it safe, a good set of CFLAGS would be

./configure CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

You should read up on CFLAGS and what they do before trying anything. I recommend you read through these links.
http://gcc.gnu.org/onlinedocs/gcc-3.4.1/gcc/Optimize-Options.html
http://linuxreviews.org/howtos/compiling/safe-cflags/
http://en.wikipedia.org/wiki/CFLAGS

Using the Binaries

When the compile is done and if all went well, a binary executable will reside in the code directory fs2_open_r or fs2_open_d if you configured for a debug build. Copy the binary to directory where Freespace2 is installed, and you're all set to go.

Changing Your Resolution

Odds are, you'll want to run fs2_open in a higher resolution than the default 640x480. Unfortunately, we Linux users don't have the swank launcher app that the Windows folks do. Instead, we'll be making a couple line changes to a config file. You will need to run fs2_open once before you can make the necessary changes, otherwise you won't have a configuration directory to work with.

The first thing we need to do is get into the fs2_open config directory, which is a hidden folder in your home directory. The fastest way to get there is to type the following in a console:

cd ~/.fs2_open

From here, open up fs2_open.ini in your text editor of choice (vi, EMACS, joe, pico, etc). You'll see something like the following:

[Default]
VideocardFs2open=OGL -(640x480)x16 bit
LastPlayer=MonkeyboyS
GammaD3D=1.0

Then change the Videocard line to the following:

VideocardFs2open=OGL -(1024x768)x32 bit

Save the file, and run fs2_open as you normally would. Voila! You're now in 1024x768 at 32bit color. Congratulations!

Creating a Start Up Script

Note: This tutorial assumes some fundamental command line knowledge.

In order to use all of the advanced engine features of fs2_open, you'll need to start the executable with a number of command line arguments. Instead of typing them in every time you want to start the game, why not create a script that does it for you?

Create a new file named start_freespace (or whatever you like) in your home directory. Open the file in your editor of choice, and paste the following:

#!/bin/sh
cd /path/to/your/freespace/
fs2_open_r -spec -glow -mipmap -jpgtga -orbradar -mod Media_VP

Note: You will need to edit this script before it will work properly. The second line must point to the directory where you installed fs2_open.

The last line starts fs2_open with a number of arguments that turn on extra features. In the example, the game will use specular highlights, glow-mapping, mipmapping, jpg and tga graphic files, the orb radar, and any MediaVPs installed to the /Media_VP directory. You should edit this line to use those features that your system supports.

More information about the available Command Line Arguments can be found at the Command-Line Reference

Once you've edited the file to your heart's content, make it executable:

chmod +x start_freespace

You can now type in start_freespace to start the game, or by clicking on start_freespace in your window manager. For convenience, you can copy it to your Desktop.