How to compile

From The Cataclysm: Dark Days Ahead Wiki
Revision as of 02:01, 6 October 2013 by 84.202.193.158 (talk) (Added link to monofur. Replaced "square fonts" with "monospace")
Jump to navigation Jump to search

Windows

There are a few ways to run Cataclysm-DDA in Windows.

Cygwin

Cygwin is not currently compatible with SDL 1.2 and therefore is unable to do tiles builds.

Start off by downloading cygwin from the official site. Currently you must download the 32-bit version as some of the required packages are missing from the 64-bit installation. Follow the download instructions on the site, and select all of the following packages when prompted to:

  • make
  • G++
  • libncurses-dev
  • libncursesw-dev
  • libiconv
  • libintl
  • gettext
  • git

Compile

Once it's finished installing, run the program which should open a terminal window, from there, type:

git clone git://github.com/CleverRaven/Cataclysm-DDA.git

Wait for it to finish downloading, then type:

cd cataclysm-dda

Once in the folder type:

make

At this point, Cataclysm should begin compiling. Once it finishes compiling, type:

./cataclysm

in order to run it.

Run

In order to run Cataclysm in the future, you need to open Cygwin, type:

cd cataclysm-dda

and type:

./cataclysm

Update

To update, simply open the folder and type:

git pull

then:

make clean

and:

make

MinGW & Msys

First download the MinGW + MSYS bundle. Then you need to download the source code of Cataclysm-DDA. There's two ways of doing so:


Option 1) Download the compressed source code and unpack it somewhere.

Option 2) (Recommended) Install GitHub for Windows. Browse to the repository and click the "Clone in Windows" button. The GitHub application will then install the repository in your GitHub folder (which can be changed in the Tools settings).


Once you have the source code run the MinGW shell, navigate to the directory where you put the code.

Example:

cd "C:\<some directories>\Cataclysm-DDA" 

if you for example type cd C:\Users\Documents\Cataclysm-DDA You get Nothing as a result so type it as cd C:\Users (press enter) then cd Documents (press enter) then cd Cataclysm-DDA to get to the directory

Then type:

make -f makefile.windows

Once compiled, run the executable (cataclysm.exe) located in that directory.

Note: To redistribute, you only need the data folder and executable.

Updating

Download the source code of the updated version. If you use the Github method just right-click the repository in Github for Windows and click "Open". Then click the "Sync" button at the top.

Once you have it, open the MinGW shell and type:

make clean

And then:

make -f makefile.windows

Code::Blocks

  • Download and install code::blocks.
  • Get the current git code using the steps discussed in the MinGW section above
  • Load the codeblocks project.
  • Press "build and run the active project" in the Code::blocks program.

Note: Sometimes Code::Blocks project file may be outdated, so check if all .cpp and .h files from the source folder are listed in your project.

For help building the tiles/SDL version, see this comment: http://smf.cataclysmdda.com/index.php?topic=1807.msg22249#msg22249

Fighting with libintl_gettext errors

General advices include:

  • go to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
  • get the gettext-runtime and gettext-runtime-dev (the latest versions). Extract them to a folder somewhere.
  • Point you library path to the \lib folder and your include path to the \include folder. For Code::Blocks right click on your project in the project tree and choose "Build options". Open "Linker" tab and add path to libintl.lib (with the file!) from gettext-runtime-dev.
  • Place the .dll files into the same directory you create your Cataclysm.exe file in. You'll need intl.dll (not found in gettext-runtime-dev, download separately) and libintl.dll (found in gettext-runtime-dev).

Visual C++ 2010

  • If you don't already have Visual C++ 2010, download and install the Express edition.
  • Get the current git code using the steps discussed in the MinGW section above.
  • Browse to the "msvc100" directory and open Cataclysm.sln.
  • Select the "Release" configuration and choose your architecture ("Win32" or "x64").
  • Press the "Build Solution" toolbar button (or press F7).
  • Browse to the appropriate output directory and copy Cataclysm.exe into the base directory.

Linux

Compilation instructions differ by distribution.

Get your friendly command-line terminal pumped and ready, grab some curdled popcorn, and pull up a mouldering chair.

Gentoo

Gentoo offers built-in support for installing Cataclysm: DDA straight from GitHub sources. Which is rather nice, really.

Installation

  1. Install layman, if not already.
  2. emerge layman
  3. Add overlay raiagent.
  4. layman -a raiagent
  5. Unmask cataclysm-dda by adding the following line to /etc/portage/package.accept_keywords.
  6. >=games-roguelike/cataclysm-dda-0.4
  7. Emerge cataclysm-dda.
  8. emerge cataclysm-dda

Assuming /usr/games/bin to be in your current ${PATH}, Cataclysm: DDA should now be runnable as cataclysm-dda. (A rehash may be required.)

raiagent also offers a live ebuild installing the most recent Cataclysm: DDA commit. Since such commits tend to be of "dubious stability," this ebuild is currently hard-masked. To unmask it, add the following line to /etc/portage/package.unmask:

~games-roguelike/cataclysm-dda-9999

"Give 'em hell, kid."

Upgrading

  1. Move aside your old save/ subdirectory.
  2. mv /usr/games/cataclysm-dda/save /tmp/
  3. Upgrade cataclysm-dda.
  4. emerge cataclysm-dda

Since Cataclysm: DDA guarantees no backward compatibility with content saved by a prior version (e.g., characters, worlds, configuration files), failure to move aside your old save/ subdirectory often results in an STL exception on game startup resembling:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr

Ubuntu

First, open the terminal. On Ubuntu, it is accessible under Applications / Accessories. Now, let's install the dependencies we'll need. It may ask you to type in your password or Y to confirm. Do it and continue.

sudo apt-get install libncurses5-dev libncursesw5-dev g++ git-core

This is it. Now to pull the source. You're likely in your "home" or "root" directory in the terminal. You can use ls to list the directories and cd to move into them. Once you are where you want the source to be, type:

git clone git://github.com/CleverRaven/Cataclysm-DDA.git

This'll make a directory called Cataclysm-DDA and pull the source into it. It might take a while.

Type cd Cataclysm-DDA to move into the directory. Now type make to compile it. If it fails, try make clean.

If it works, try running the game with ./cataclysm. If that also works, you're ready to mod.

To update the game, move into the game directory and write "git pull". Afterwards, type make clean (which clears all object files and such) and make. There, updated!

To compile SDL version you'll need to install:

sudo apt-get install libsdl1.2-dev libsdl-ttf2.0-dev:i386

compiling command will be like make TILES=1

Run the game with ./cataclysm-tiles. It should be mentioned that SDL version sometimes runs smoother and faster.

Mac

Mac is the least supported platform, due to almost nobody owning one. Still, it seems it's pretty much solid, some errors notwithstanding.

Fixing errors

You might get these errors when compiling:

error: no matching function for call to `player_activity::player_activity(player_activity)'
note: candidates are: player_activity::player_activity(player_activity&)

This is due to non-const copy constructors (see this), which some C++ compilers just kludge for you with auto pointer magic... and others don't (like recent XCode GCC).

To fix this change:

pldata.h:113 player_activity(player_activity &copy)

to:

pldata.h:113 player_activity(player_activity const &copy)

You'll also need to change:

npc.h:197 npc_opinion(npc_opinion &copy)

to:

npc.h:197 npc_opinion(npc_opinion const &copy)

And, finally, force a 32-bit executable:

Makefile:8  OTHERS = -O3 -m32

Compile

Mac OS doesn't have apt-get, so you'll need Fink or MacPorts to to install libraries (This guide will be using MacPorts). Other than that, the setup is pretty much the same as with Linux. Note: that this guide currently only supports non-SDL, non-tiles builds.

Now, let's install the dependencies we'll need. It may ask you to type in your password or Y to confirm. Do it and continue.

sudo port install ncurses git-core gettext

Download and install https://code.google.com/p/rudix/downloads/detail?name=libintl-0.18.1.1-4.pkg

This is it. Now to pull the source. You're likely in your "home" or "root" directory in the terminal. You can use "ls" to list the directories and "cd" to move into them. Once you are where you want the source to be, type:

git clone git://github.com/CleverRaven/Cataclysm-DDA.git

This'll make a directory called Cataclysm-DDA and pull the source into it. It might take a while.

Type:

cd Cataclysm-DDA

to move into the directory. Now type:

make NATIVE=osx

to compile it. If it fails, try:

make clean

If it works, try running the game with:

./cataclysm

If that also works, you're ready to mod.

Note: Mac OS's terminal is normally set to 8-bit colors. Set it to 16-bit colors to get the colors needed for Cataclysm. An alternative may be to check the "display bright colours for bold text" on in terminal preferences / text tab.

To update the game, move into the game directory and write:

git pull

Afterwards, type:

make clean

Then:

make NATIVE=osx

There, updated!

Monospace fonts

While you can use fonts of any proportion to play the game, non-monospace fonts tend to distort the visual representation of the game world by stretching buildings, vehicles, creatures, etc vertically.

To avoid that you should use fonts specified as monospace instead. Here are some of them:

Windows

To change the font used by the game you'll need to edit the FONTDATA file, located in the Data directory. You can edit that file by using any text editor (Windows Notepad, Notepad++, etc).

It'll display something like this:

Topaz-8
16
16

Change the first line to the name of the font you want to use. The other two lines are the size of the font. Make sure both numbers are the same.

You'll have to experiment with different font and viewport sizes, by accessing the game's options menu (from the main menu scree or through ?, 2 while playing), until you get the game properly displayed at the size you want.

Linux and Mac

You can change the font and size in most terminals. Depending on the terminal you can do that by right clicking and selecting Options or a similar option, or by editing its config files.

If your terminal allows creating several profiles it'd be a good idea creating one for the only purpose of playing.