How to compile: Difference between revisions

From The Cataclysm: Dark Days Ahead Wiki
Jump to navigation Jump to search
(→‎Getting the game sources: added link description.)
(→‎Mac: added piece about how to get how to get prebuilt and whats up-to-date)
 
(14 intermediate revisions by 2 users not shown)
Line 4: Line 4:


{{delete|Wiki may not be the best place for installation details}}
{{delete|Wiki may not be the best place for installation details}}
For experimental version compilation instructions, see [https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/COMPILING/COMPILING.md /doc/COMPILING/COMPILING.md].


{{tocr}}
{{tocr}}
Line 28: Line 30:


== Linux ==
== Linux ==
Outdated, please see [https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING.md]
For further information, please see [https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING.md COMPILING.md] for up to date instructions.
Compilation instructions differ by distribution.
Compilation instructions may differ by distribution.


Get your friendly command-line terminal pumped and ready, grab some curdled popcorn, and pull up a mouldering chair.
Get your friendly command-line terminal pumped and ready, grab some curdled popcorn, and pull up a mouldering chair.
Line 49: Line 51:
<li>Unmask <tt>cataclysm-dda</tt> by adding the following line to <tt>/etc/portage/package.accept_keywords</tt>.</li>
<li>Unmask <tt>cataclysm-dda</tt> by adding the following line to <tt>/etc/portage/package.accept_keywords</tt>.</li>
<pre>>=games-roguelike/cataclysm-dda-0.4</pre>
<pre>>=games-roguelike/cataclysm-dda-0.4</pre>
<li>Enable USE flags "<tt>ncurses</tt>" (installing an ncurses-based terminal interface) <i>and/or</i> "<tt>sdl</tt>" (installing an SDL-based tiles interface) by adding a line like the following to <tt>/etc/portage/package.use</tt>. (You probably want both as well as a Lua interpreter, so we default to that.)</li>
<li>Enable USE flags "<tt>ncurses</tt>" (installing an ncurses-based terminal interface) <i>and/or</i> "<tt>sdl</tt>" (installing an SDL-based tiles interface) by adding a line like the following to <tt>/etc/portage/package.use</tt>. (You probably want both as well as a Lua interpreter, so we default to that. NOTE: Lua appeared in 0.D Danny and disappeared in 0.E Ellison)</li>
<pre>games-roguelike/cataclysm-dda lua ncurses sdl</pre>
<pre>games-roguelike/cataclysm-dda lua ncurses sdl</pre>
<li>Emerge <tt>cataclysm-dda</tt>.</li>
<li>Emerge <tt>cataclysm-dda</tt>.</li>
Line 86: Line 88:


=== Ubuntu ===
=== Ubuntu ===
(NOTE: these instructions should work for ''all'' Debian based distributions too, inlc. RaspberryPiOS - 2022)


First, open the terminal. On Ubuntu, you can find it by typing 'Terminal' into the dash and.
First, open the terminal. On Ubuntu, you can find it by typing 'Terminal' into the dash and.
Line 97: Line 101:
This'll make a directory called Cataclysm-DDA and pull the source into it. It might take a while.
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 move into the directory, type:
 
cd Cataclysm-DDA
 


==== ncurses (terminal) ====
==== ncurses (terminal) ====
Line 106: Line 113:
  sudo apt-get install libncurses5-dev libncursesw5-dev
  sudo apt-get install libncurses5-dev libncursesw5-dev


Now type ''make'' to compile it. If it fails, try ''make clean'' and retry ''make''.
To compile it, now type:
 
make  
 
If it fails, try:
 
make clean && make
 
If no errors appear, try running the game with:
 
./cataclysm
 
If that also works, you're ready to mod.


If it works, try running the game with ''./cataclysm''. If that also works, you're ready to mod.
==== Localization (languages) ====
 
To compile for your local language into Cataclysm:DDA, you need ''gettext``:
 
sudo apt-get install gettext-dev
 
To compile without localization (its ''on'' by default):
 
make LOCALIZE=0
 
To compile with a specific localization:
 
make LANGUAGES="zh_CN zh_TW"
 
If no errors appear, try running the game with:
 
./cataclysm


==== Tiles (graphical) ====
==== Tiles (graphical) ====
Line 118: Line 153:
(Ubuntu 12.04 "Precise Pangolin" uses libsdl-ttf-2.0-dev)
(Ubuntu 12.04 "Precise Pangolin" uses libsdl-ttf-2.0-dev)


Compile with ''make TILES=1''. To compile with improved performance, compile with ''make TILES=1 RELEASE=1''.
Compile with:
 
make TILES=1
 
To compile with improved performance, compile with:
 
make TILES=1 RELEASE=1
 
To test that it is working correctly, type:
 
./cataclysm-tiles
 
If the ''tileset'' in the main window is missing, but everthing else seems to be working, there may be an issue with your SDL2 installation. You can check the game is still functioning correctly by turning on the ''ScentMap'', walking around in a square, or into walls and seeing what comes up on the ''minimap'' (the ''Overview Map'' will still work too).
 
You can use ''catalysm-tiles'' in ASCII mode by changeing the ''tileset'' in the ''Graphics Options'', where the ''minimap'' is still pixel based.
 
==== Sound (requires Tiles) ====
 
To compile with sound you need the Tiles graphical SDL version (for Ubuntu 14.04):
 
sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
 
Compile with:
 
make TILES=1 SOUND=1
 
To compile with improved performance, compile with:
 
make TILES=1 SOUND=1 RELEASE=1
 
To test that it is working correctly, type:
 
./cataclysm-tiles
 
Moving with the cursor keys on the menus, you should hear a ''chime-like click'' sound. If you dont hear anything, there maybe an issue with your SDL2 installation.
 
==== Fast Compile (English only) ====
 
You can speed up the compile time by not running the developer tests (needed to verify data when you are modding). By using ''RELEASE=1'' the default build with debug symbols is turned off, which also offers a perfomance boost at runtime.
You also may want to install your new build along side your (older) OS distributions version of Cataclysm:DDA, in which case it needs to be in a different location.
 
With graphics, sound, and no localization, compile with:
 
make RELEASE=1 USE_HOME_DIR=1 TILES=1 SOUND=1 LOCALIZE=0 ASTYLE=0 LINTJSON=0 RUNTESTS=0 PREFIX=/usr/local
 
After that completes you can install it with:
 
make install RELEASE=1 USE_HOME_DIR=1 TILES=1 SOUND=1 LOCALIZE=0 ASTYLE=0 LINTJSON=0 RUNTESTS=0 PREFIX=/usr/local
 
To find out which ''cataclysm'' is install and where, type:
 
which -a cataclysm-tiles


==== Further activities ====
==== Further activities ====


Lua scripting can be enabled by installing the dependency ''lua5.1-dev'' and adding ''LUA=1'' to the make arguments.
From version 0.D ''Danny'', Lua scripting can be enabled by installing the dependency ''lua5.1-dev'' and adding ''LUA=1'' to the make arguments. Note that Lua scripting was removed with the release of 0.E ''Ellison''.


Run the game with ''./cataclysm-tiles''. It should be mentioned that SDL version sometimes runs smoother and faster.
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'' to build again. There, updated!
To update the game, move into the ''Cataclysm-DDA'' directory (where you did the ''git clone'') and type "git pull". Afterwards, type ''make clean'' (which clears all object files and such) and ''make'' to build again. There, updated! eg:
 
make clean && make (replace this with any options you used last time)


== Mac ==
== Mac ==
Mac is the least supported platform, due to almost nobody owning one. Still, it seems it's pretty much solid, some errors notwithstanding.
Mac is the least supported platform, due to almost nobody owning one. Still, it seems it's pretty much solid, some errors notwithstanding.
Note: some of this may no longer be applicable, 0.G is about to be released, and [https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/COMPILING/COMPILING.md#mac-os-x compiling CDDA on OSX] is well documented and well tested. Catalysm-DDA is available  from ''HomeBrew'', and there are ''dmg'' packages available on the repository [https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/0.F releases] page (also for [https://github.com/CleverRaven/Cataclysm-DDA/tags experimental] biulds).


=== Fixing errors ===
=== Fixing errors ===

Latest revision as of 03:54, 26 January 2022

Guide created using an unknown version of Cataclysm DDA.
The information present here might not apply to the current version of CDDA.




For experimental version compilation instructions, see /doc/COMPILING/COMPILING.md.

Windows

Getting the game sources

CodeBlocks + MinGW

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 forum topics:

Linux

For further information, please see COMPILING.md for up to date instructions. Compilation instructions may 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

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. NOTE: Lua appeared in 0.D Danny and disappeared in 0.E Ellison)
  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 with empty KEYWORDS. To unmask it, add the following line to /etc/portage/package.accept_keywords:

~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

(NOTE: these instructions should work for all Debian based distributions too, inlc. RaspberryPiOS - 2022)

First, open the terminal. On Ubuntu, you can find it by typing 'Terminal' into the dash and.

In order to download the latest version of Cataclysm:DDA, we will need to install git. You'll probably need to type in your password.

sudo apt-get install git

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. Move onto the directory where you want your game to be installed then proceed:

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.

To move into the directory, type:

cd Cataclysm-DDA


ncurses (terminal)

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

sudo apt-get install build-essential
sudo apt-get install libncurses5-dev libncursesw5-dev

To compile it, now type:

make 

If it fails, try:

make clean && make

If no errors appear, try running the game with:

./cataclysm

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

Localization (languages)

To compile for your local language into Cataclysm:DDA, you need gettext``:

sudo apt-get install gettext-dev

To compile without localization (its on by default):

make LOCALIZE=0

To compile with a specific localization:

make LANGUAGES="zh_CN zh_TW"

If no errors appear, try running the game with:

./cataclysm

Tiles (graphical)

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

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

(Ubuntu 12.04 "Precise Pangolin" uses libsdl-ttf-2.0-dev)

Compile with:

make TILES=1

To compile with improved performance, compile with:

make TILES=1 RELEASE=1

To test that it is working correctly, type:

./cataclysm-tiles

If the tileset in the main window is missing, but everthing else seems to be working, there may be an issue with your SDL2 installation. You can check the game is still functioning correctly by turning on the ScentMap, walking around in a square, or into walls and seeing what comes up on the minimap (the Overview Map will still work too).

You can use catalysm-tiles in ASCII mode by changeing the tileset in the Graphics Options, where the minimap is still pixel based.

Sound (requires Tiles)

To compile with sound you need the Tiles graphical SDL version (for Ubuntu 14.04):

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

Compile with:

make TILES=1 SOUND=1

To compile with improved performance, compile with:

make TILES=1 SOUND=1 RELEASE=1

To test that it is working correctly, type:

./cataclysm-tiles

Moving with the cursor keys on the menus, you should hear a chime-like click sound. If you dont hear anything, there maybe an issue with your SDL2 installation.

Fast Compile (English only)

You can speed up the compile time by not running the developer tests (needed to verify data when you are modding). By using RELEASE=1 the default build with debug symbols is turned off, which also offers a perfomance boost at runtime. You also may want to install your new build along side your (older) OS distributions version of Cataclysm:DDA, in which case it needs to be in a different location.

With graphics, sound, and no localization, compile with:

make RELEASE=1 USE_HOME_DIR=1 TILES=1 SOUND=1 LOCALIZE=0 ASTYLE=0 LINTJSON=0 RUNTESTS=0 PREFIX=/usr/local

After that completes you can install it with:

make install RELEASE=1 USE_HOME_DIR=1 TILES=1 SOUND=1 LOCALIZE=0 ASTYLE=0 LINTJSON=0 RUNTESTS=0 PREFIX=/usr/local

To find out which cataclysm is install and where, type:

which -a cataclysm-tiles

Further activities

From version 0.D Danny, Lua scripting can be enabled by installing the dependency lua5.1-dev and adding LUA=1 to the make arguments. Note that Lua scripting was removed with the release of 0.E Ellison.

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 Cataclysm-DDA directory (where you did the git clone) and type "git pull". Afterwards, type make clean (which clears all object files and such) and make to build again. There, updated! eg:

make clean && make (replace this with any options you used last time)

Mac

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

Note: some of this may no longer be applicable, 0.G is about to be released, and compiling CDDA on OSX is well documented and well tested. Catalysm-DDA is available from HomeBrew, and there are dmg packages available on the repository releases page (also for experimental biulds).

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 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 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. OS 10.10, Yosemite, seems to require

make NATIVE=osx OSX_MIN=10.7 CLANG=1

or

make NATIVE=osx OSX_MIN=10.7 CLANG=1 MACPORTS=1

if you're using Macports 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:

Changing the font

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)"

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.