How to compile

From The Cataclysm: Dark Days Ahead Wiki
Jump to: navigation, search

Contents

[edit] Windows

There are a few ways to run Cataclysm-DDA in Windows. The recommended way to compile cataclysm on windows is MinGW, as the Makefile is more likely to be updated than the CodeBlocks and VisualStudio project files. (Note: You can set up CodeBlocks to use the Makefile, instructions to do this may follow later)


[edit] MinGW with MSYS

First you need to download and install MinGW and MSYS.

In the installer, choose your preferred location (a path without spaces is recommended both for MinGW and CDDA).
All the other options can be left at their default.

Once installed, mingw-get-gui will open, which will allow you to install and uninstall programs and libraries.
In "Basic Setup", mark mingw-developer-toolkit, mingw32-base and mingw32-gcc-g++ for installation by left-click the checkboxes.
Then install these components using "Installation -> Apply Changes".

XmuWAMA.png

Furthermore, we will need gettext and libintl. In "All Packages -> MinGW -> MinGW Autotools" ensure that mingw32-gettext and mingw32-libintl are installed.

Optionally, when compiling with TILES or LUA support, Cataclysm DDA will also need these libraries:

You can find a prepackaged version of these libraries here: http://46.102.243.119/public/CDDA-deps.zip Simply unzip this archive into your MinGW root directory.

[edit] Fixing the Makefile

The Makefile currently tries to produce a static build. This means that no .dll's are required to run the game. However, this doesn't work with the MinGW release of SDL_ttf and SDL_image, which ship with .dll's.

Open CDDA/Makefile in a text editor(e.g. notepad++) and look for the line "LDFLAGS += -static". Replace this line with the following and save the file: "LDFLAGS += -static-libgcc -static-libstdc++"

[edit] Compile

Once you have MinGW and all Cataclysm dependencies properly installed:

  1. Ensure you have downloaded the Cataclysm DDA source code.
  2. Navigate to MinGW/msys/1.0/ and start msys.bat.
  3. Add the MinGW toolchain to your PATH with export PATH=$PATH:/c/MinGW/bin. Replace /c/MinGW/ with the directory into which you installed MinGW (/c/ stands for drive C:, so if it's in F:/foo/bar, you'd use /f/foo/bar).
  4. Navigate to the CDDA source code directory using cd /c/Users/blub/CDDA, again, replace /c/Users/blub/CDDA with the path where you extracted it.
  5. Compile using make TILES=1 NATIVE=win32 and unless there are problems, it should produce a CDDA binary for you.
  6. Copy the .dll's in the "bin" directory in CDDA-deps.zip into your CDDA directory.

[edit] 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. 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

[edit] Compile

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

# clone the repository
git clone git://github.com/CleverRaven/Cataclysm-DDA.git

# once downloaded, get into the source directory
cd cataclysm-dda

# start compiling
make

# run the fresh executable
./cataclysm

[edit] Update

To update to the latest repository version, open the source directory and type:

# get into the source directory
cd cataclysm-dda

# update the source code to the lastest version
git pull

# purge unnecessary files
make clean

# recompile
make

# run the fresh executable
./cataclysm

[edit] 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 these comments:

[edit] 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).

[edit] 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.

[edit] 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.

[edit] Gentoo

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

[edit] Installation

Run the following commands at your favorite command-line terminal as the superuser (i.e., root):

  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. Enable USE flags "ncurses" (installing an ncurses-based terminal interface) and/or "sdl" (installing an SDL-based tiles interface) by adding a line like the following to /etc/portage/package.use. (You probably want both as well as a Lua interpreter, so we default to that.)
  8. games-roguelike/cataclysm-dda lua ncurses sdl
  9. Emerge cataclysm-dda.
  10. emerge cataclysm-dda

Assuming /usr/games/bin to be in your current ${PATH}, Cataclysm: DDA should now be runnable as either:

  • cataclysm-dda-ncurses, assuming you enabled USE flag "ncurses" above.
  • cataclysm-dda-sdl, assuming you enabled USE flag "sdl" above.

(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."

[edit] 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

[edit] Ubuntu

First, open the terminal. On Ubuntu, it is accessible under Applications / Accessories. First we'll need to install git. You'll probably need to type in your password and maybe Y to confirm.

sudo apt-get install git-core

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.

To compile the terminal version you'll need to install some dependencies:

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

Now type make to compile it. If it fails, try make clean and retry make.

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

To compile the graphical SDL version (for Ubuntu 14.04):

sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev

(Ubuntu Precise uses libsdl-ttf-2.0-dev)

(an older version of Cataclysm required: sudo apt-get install libsdl1.2-dev libsdl-ttf2.0-dev:i386)

compile with make TILES=1

Lua scripting can be enabled by installing the dependency lua5.1-dev and adding LUA=1 to the make arguments.

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

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

[edit] Mac

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

[edit] 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

[edit] Compile

Mac OS doesn't have apt-get, so you'll need Fink or MacPorts 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!

[edit] 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:

[edit] Changing the font

[edit] 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). Or you could rename it and give it a .txt extension or open it a build in text editor. Don't forget to remove the .txt extension after editing it.

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. Cataclysm will stretch some fonts to make them bigger, where as with other fonts it will just increase the spacing between tiles. The numbers represent the size of the font in pixels, they do not have to be equal.

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.

You may be able to try using fixedsys as it ships with cataclysm. If it does not work you will have to put the fixedsys.ttf font from your cataclysm\data\font folder into your windows font folder.

One more thing to mention, in order to use a font from your windows font folder with cataclysm you have to type the "name" of the font into FONTDATA. In order to find the font name you have to open the font, and look at the very top line of the file. Write down the name exactly as it appears except leave out any bits in ()'s. For example with the fixedsys font. You would type "Fixedsys TTF V5.00c" and NOT "Fixedsys TTF V5.00c (True Type)"

[edit] 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.

Guides
Guides Choosing Martial Arts Styles · How to survive your first day: (Dynamic Spawn Mode | Static Spawn Mode) · Beyond the first day · Killing zombies · Making a Supercar · Night Raids · Nomadic Living · Woodland Survival · FAQ · Beginner Character Build Tips · Farming
Advanced Guides Fungal Bloom · Marloss Berry · Mine · Strange Temple · Triffid Grove
Technical Mod Manager · CataModder · Cheating · How to compile · Tileset Support
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox