v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User:Khearn/DfhackLinuxBuild

From Dwarf Fortress Wiki
< User:Khearn
Revision as of 22:05, 27 August 2014 by Khearn (talk | contribs) (→‎Getting the sources: Fixed incorrect URLs)
Jump to navigation Jump to search

HOWTO build dfhack on linux

This page describes (or attempts to) how to build dfhack from sources on a linux system. I have a Unbuntu 14.04 64-bit system, and this was written while 40.10 was the current DF version. If your linux system is different or you are building for a different DF version, you may find that not everything works exactly as I describe, but hopefully this will at least provide some help.

Installing Libraries & other Packages

One complication that I had to deal with is that DF is a 32-bit binary (as of 40.10 at least), so dfhack also has to be 32-bit, but my linux system is 64-bit. This means that most of the shared libraries installed on my system are 64-bit, and won't work for dfhack. SO I had to figure out what packages I needed and install them. Naturally, I didn't make a list as I went along, so this list may be a bit incomplete. Plus, I may have already had some 32-bit libs that I needed already on my system, so I didn't notice that they were needed.

But even if you have a 32-bit system, you still may need to install some packages that you don't already have.

BTW, to tell if you are on 32-bit or 64-bit, run 'uname -p'. If you see something like 'x86_64', your system is 64-bit, if you see something like 'i386' or maybe 'x86_32', then yours is a 32-bit system. I don't know exactly what a 32-bit system will print out, since i don't have one handy to test it on.

Installing packages

I'll describe how packages get installed on my Unbuntu system. Different linux distributions have different commands, so you may need to figure out how to do it on your system if this doesn't work. Google is your friend.

I prefer to use a GUI-based package manager, the Synaptic Package Manager. But if you don't have synaptic installed, you can install stuff from the command line of you know the exact package name. Using Synaptic allows you to search through package names, which is handy if you know you need gcc, but aren't sure what the package is named.

For installing packages from the command line, the command to use is 'apt-get install <package>'. For instance, to install Synaptic, I'd do 'sudo apt-get install synaptic'. The 'sudo' causes the command to be run as root. You have to be authorized to run sudo on your system, and you'll be prompted for your login password. If you can't run sudo or become root in some way, you can't install packages and you're basically out of luck.

One package may require other packages to be installed first. If this is the case, spt-get will list the packages that will need to be installed and ask you if you want to install them as well. Say yes.

If you already have the package installed, it doesn't hurt to try and install it again. You might even find that you have an old version and end up upgrading.

So here are the packages I can recall needing to install:

  • git
  • gcc-4.9-base:i386 (You can go with some other version)
  • libstdc++6:i386
  • zlib1g:i386
  • cmake
  • cmake-curses-gui (also known as ccmake)
  • libxml-xslt-perl
  • libxml-perl

If you discover others that I didn't list here, let me know and I'll add them.

Getting the sources

The sources are on github.com, and you'll need to set up a github account to get them. So go to github.com and there will be something to tell you how to set up an account.

The sources I used are Quietust's "develop" branch. It can be found at https://github.com/quietust/dfhack/tree/develop. The command to get that branch is:

git clone -b develop https://github.com/quietust/dfhack.git

That will copy the main part of the code down to your system, but there are some submodules that need to be downloaded as well.

cd dfhack
git submodule init
git submodule update

Building dfhack

Now you should have all the sources and are ready to build it.

cd build
cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTAL_PREFIX=<path to your DF directory>

Dfhack needs to know where it will install the files, so you have to tell it where you have DF installed.

On my system, cmake consistently found the wrong location for the zlib library and tried to use the 64-bit version. So at this point I have to edit build/CMakeCache.txt and change the line with "ZLIB_LIBRAY:FILEPATH=/usr/lib/x86_64-linux-gnu/libz.so" to be "ZLIB_LIBRAY:FILEPATH=/lib/i386-linux-gnu/libz.so.1". You may or may not have to do this. If your build fails because it can't find "-lz", this may be the issue.

Now you're ready to try the build.

make install

This will be the acid test to see if you have all the libraries you need. If you've got everything, it should build and install and you'll find a dfhack executable in your DF directory. If there are errors, it's likely to be because you need some packages.