2015-09-22 08:06:56 -06:00
|
|
|
################
|
|
|
|
Compiling DFHack
|
|
|
|
################
|
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
You don't need to compile DFHack unless you're developing plugins or working on the core.
|
|
|
|
|
|
|
|
For users, modders, and authors of scripts it's better to download
|
|
|
|
and `install the latest release instead <installing>`.
|
2010-07-19 21:27:12 -06:00
|
|
|
|
|
|
|
.. contents::
|
2015-11-05 03:40:09 -07:00
|
|
|
:depth: 2
|
|
|
|
|
2011-07-30 21:50:37 -06:00
|
|
|
|
2012-02-24 12:25:53 -07:00
|
|
|
How to get the code
|
|
|
|
===================
|
2015-09-22 08:06:56 -06:00
|
|
|
DFHack doesn't have any kind of system of code snapshots in place, so you will have to
|
2015-11-05 22:58:58 -07:00
|
|
|
get code from the github repository using git. How to get git is described under
|
|
|
|
the instructions for each platform.
|
2012-02-24 12:25:53 -07:00
|
|
|
|
2015-07-24 08:49:17 -06:00
|
|
|
To get the code::
|
|
|
|
|
|
|
|
git clone --recursive https://github.com/DFHack/dfhack
|
|
|
|
cd dfhack
|
|
|
|
|
|
|
|
If your version of git does not support the ``--recursive`` flag, you will need to omit it and run
|
|
|
|
``git submodule update --init`` after entering the dfhack directory.
|
|
|
|
|
2015-11-05 22:58:58 -07:00
|
|
|
If you want to get involved with the development, create an account on
|
2015-09-22 08:06:56 -06:00
|
|
|
Github, make a clone there and then use that as your remote repository instead.
|
2015-11-05 22:58:58 -07:00
|
|
|
We'd love that; join us on IRC (#dfhack channel on freenode) if you need help.
|
2015-07-24 08:49:17 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
|
2015-09-22 08:06:56 -06:00
|
|
|
Build types
|
|
|
|
===========
|
2015-11-05 22:58:58 -07:00
|
|
|
``cmake`` allows you to pick a build type by changing the ``CMAKE_BUILD_TYPE`` variable::
|
2015-09-22 08:06:56 -06:00
|
|
|
|
|
|
|
cmake .. -DCMAKE_BUILD_TYPE:string=BUILD_TYPE
|
|
|
|
|
|
|
|
Without specifying a build type or 'None', cmake uses the
|
|
|
|
``CMAKE_CXX_FLAGS`` variable for building.
|
|
|
|
|
|
|
|
Valid and useful build types include 'Release', 'Debug' and
|
|
|
|
'RelWithDebInfo'. 'Debug' is not available on Windows.
|
2015-07-24 08:49:17 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
|
2015-07-24 08:49:17 -06:00
|
|
|
Linux
|
|
|
|
=====
|
|
|
|
On Linux, DFHack acts as a library that shadows parts of the SDL API using LD_PRELOAD.
|
2012-02-24 12:25:53 -07:00
|
|
|
|
2010-07-19 21:27:12 -06:00
|
|
|
Dependencies
|
2015-11-05 03:40:09 -07:00
|
|
|
------------
|
2011-07-30 21:50:37 -06:00
|
|
|
DFHack is meant to be installed into an existing DF folder, so get one ready.
|
2010-07-19 21:27:12 -06:00
|
|
|
|
2015-11-05 22:58:58 -07:00
|
|
|
We assume that any Linux platform will have ``git`` available.
|
|
|
|
|
2015-11-10 16:43:34 -07:00
|
|
|
To build DFHack you need a version of GCC 4.x capable of compiling for 32-bit
|
|
|
|
(i386) targets. GCC 4.5 is easiest to work with due to avoiding libstdc++ issues
|
|
|
|
(see below), but any later 4.x version should work as well. GCC 5.x will not
|
|
|
|
work due to ABI changes (the entire plugin loading system won't work, for
|
|
|
|
example). On 64-bit distributions, you'll need the multilib development tools
|
|
|
|
and libraries (``gcc-multilib`` or ``gcc-4.x-multilib`` on Debian). Note that
|
|
|
|
installing a 32-bit GCC on 64-bit systems (e.g. ``gcc:i386`` on Debian) will
|
|
|
|
typically *not* work, as it depends on several other 32-bit libraries that
|
|
|
|
conflict with system libraries. Alternatively, you might be able to use ``lxc``
|
2015-11-07 15:18:50 -07:00
|
|
|
to
|
2015-11-05 03:40:09 -07:00
|
|
|
:forums:`create a virtual 32-bit environment <139553.msg5435310#msg5435310>`.
|
2011-07-30 21:50:37 -06:00
|
|
|
|
|
|
|
Before you can build anything, you'll also need ``cmake``. It is advisable to also get
|
|
|
|
``ccmake`` on distributions that split the cmake package into multiple parts.
|
|
|
|
|
2015-02-05 19:24:19 -07:00
|
|
|
You also need perl and the XML::LibXML and XML::LibXSLT perl packages (for the code generation parts).
|
2015-11-05 22:58:58 -07:00
|
|
|
You should be able to find them in your distro repositories.
|
2011-12-24 06:44:14 -07:00
|
|
|
|
2015-11-05 22:58:58 -07:00
|
|
|
* On Arch linux, ``perl-xml-libxml`` and ``perl-xml-libxslt`` (or through ``cpan``)
|
|
|
|
* On 64-bit Ubuntu, ``apt-get install zlib1g-dev:i386 libxml-libxml-perl libxml-libxslt-perl``.
|
2015-11-10 14:57:38 -07:00
|
|
|
* On 32-bit Ubuntu, ``apt-get install gcc-multilib g++-multilib zlib1g-dev libxml-libxml-perl libxml-libxslt-perl``.
|
2015-11-05 22:58:58 -07:00
|
|
|
* Debian-derived distros should have similar requirements.
|
2014-08-15 22:18:33 -06:00
|
|
|
|
2015-11-05 22:58:58 -07:00
|
|
|
To build Stonesense, you'll also need OpenGL headers.
|
2015-11-05 03:40:09 -07:00
|
|
|
|
2015-08-10 08:12:40 -06:00
|
|
|
|
2011-07-30 21:50:37 -06:00
|
|
|
Build
|
2015-11-05 03:40:09 -07:00
|
|
|
-----
|
2015-09-24 04:17:58 -06:00
|
|
|
Building is fairly straightforward. Enter the ``build`` folder (or create an
|
|
|
|
empty folder in the DFHack directory to use instead) and start the build like this::
|
2015-03-04 15:33:12 -07:00
|
|
|
|
2010-07-19 21:27:12 -06:00
|
|
|
cd build
|
2011-07-30 21:50:37 -06:00
|
|
|
cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/home/user/DF
|
|
|
|
make install
|
2011-03-13 12:38:32 -06:00
|
|
|
|
2011-07-30 21:50:37 -06:00
|
|
|
Obviously, replace the install path with path to your DF. This will build the library
|
|
|
|
along with the normal set of plugins and install them into your DF folder.
|
2011-03-13 12:38:32 -06:00
|
|
|
|
2011-07-30 21:50:37 -06:00
|
|
|
Alternatively, you can use ccmake instead of cmake::
|
2015-03-04 15:33:12 -07:00
|
|
|
|
2011-03-13 12:38:32 -06:00
|
|
|
cd build
|
|
|
|
ccmake ..
|
2011-07-30 21:50:37 -06:00
|
|
|
make install
|
2011-03-13 12:38:32 -06:00
|
|
|
|
|
|
|
This will show a curses-based interface that lets you set all of the
|
2015-11-05 22:58:58 -07:00
|
|
|
extra options. You can also use a cmake-friendly IDE like KDevelop 4
|
|
|
|
or the cmake-gui program.
|
2011-03-13 12:38:32 -06:00
|
|
|
|
2010-07-19 21:27:12 -06:00
|
|
|
|
2015-11-05 22:58:58 -07:00
|
|
|
Incompatible libstdc++
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
2015-11-07 15:18:50 -07:00
|
|
|
When compiling dfhack yourself, it builds against your system libstdc++.
|
2013-04-03 14:28:11 -06:00
|
|
|
When Dwarf Fortress runs, it uses a libstdc++ shipped with the binary, which
|
2015-07-24 08:49:17 -06:00
|
|
|
comes from GCC 4.5 and is incompatible with code compiled with newer GCC versions.
|
|
|
|
This manifests itself with the error message::
|
2013-04-03 14:28:11 -06:00
|
|
|
|
|
|
|
./libs/Dwarf_Fortress: /pathToDF/libs/libstdc++.so.6: version
|
|
|
|
`GLIBCXX_3.4.15' not found (required by ./hack/libdfhack.so)
|
|
|
|
|
2015-11-07 15:18:50 -07:00
|
|
|
To fix this, you can compile with GCC 4.5 or remove the libstdc++ shipped with
|
|
|
|
DF, which causes DF to use your system libstdc++ instead::
|
2013-04-03 14:28:11 -06:00
|
|
|
|
|
|
|
cd /path/to/DF/
|
|
|
|
rm libs/libstdc++.so.6
|
|
|
|
|
2015-11-07 15:18:50 -07:00
|
|
|
Note that distributing binaries compiled with newer GCC versions requires end-
|
|
|
|
users to delete libstdc++ themselves and have a libstdc++ on their system from
|
|
|
|
the same GCC version or newer. For this reason, distributing anything compiled
|
|
|
|
with GCC versions newer than 4.8 is discouraged.
|
2015-11-05 03:40:09 -07:00
|
|
|
|
2012-10-16 13:58:34 -06:00
|
|
|
Mac OS X
|
|
|
|
========
|
2015-07-24 08:49:17 -06:00
|
|
|
DFHack functions similarly on OS X and Linux, and the majority of the
|
|
|
|
information above regarding the build process (cmake and make) applies here
|
|
|
|
as well.
|
|
|
|
|
2015-11-07 15:18:50 -07:00
|
|
|
If you have issues building on OS X 10.10 (Yosemite) or above, try definining the
|
2015-11-05 03:40:09 -07:00
|
|
|
following environment variable::
|
2013-03-14 12:42:15 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.9
|
|
|
|
|
|
|
|
#. Download and unpack a copy of the latest DF
|
|
|
|
#. Install Xcode from Mac App Store
|
|
|
|
#. Open Xcode, go to Preferences > Downloads, and install the Command Line Tools.
|
|
|
|
#. Install dependencies
|
2012-10-20 07:06:33 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
Using `Homebrew <http://brew.sh/>`_::
|
2015-07-24 08:49:17 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
brew tap homebrew/versions
|
|
|
|
brew install git
|
|
|
|
brew install cmake
|
|
|
|
brew install gcc45
|
2015-07-24 08:49:17 -06:00
|
|
|
|
2015-11-06 17:35:44 -07:00
|
|
|
Using `MacPorts <https://www.macports.org>`_::
|
2015-03-04 15:33:12 -07:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
sudo port install gcc45 +universal cmake +universal git-core +universal
|
2015-03-04 15:33:12 -07:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
Macports will take some time - maybe hours. At some point it may ask
|
|
|
|
you to install a Java environment; let it do so.
|
2012-10-20 07:06:33 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
#. Install perl dependencies
|
2012-10-20 07:06:33 -06:00
|
|
|
|
|
|
|
1. ``sudo cpan``
|
|
|
|
|
|
|
|
If this is the first time you've run cpan, you will need to go through the setup
|
|
|
|
process. Just stick with the defaults for everything and you'll be fine.
|
|
|
|
|
2015-11-07 15:18:50 -07:00
|
|
|
If you are running OS X 10.6 (Snow Leopard) or earlier, good luck!
|
2015-11-06 17:35:44 -07:00
|
|
|
You'll need to open a separate Terminal window and run::
|
2015-11-05 03:40:09 -07:00
|
|
|
|
|
|
|
sudo ln -s /usr/include/libxml2/libxml /usr/include/libxml
|
|
|
|
|
2012-10-20 07:06:33 -06:00
|
|
|
2. ``install XML::LibXML``
|
|
|
|
3. ``install XML::LibXSLT``
|
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
#. Get the dfhack source::
|
2012-10-20 07:06:33 -06:00
|
|
|
|
2015-07-24 08:49:17 -06:00
|
|
|
git clone --recursive https://github.com/DFHack/dfhack.git
|
2012-10-20 07:06:33 -06:00
|
|
|
cd dfhack
|
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
#. Set environment variables:
|
2014-02-24 15:46:08 -07:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
Homebrew (if installed elsewhere, replace /usr/local with ``$(brew --prefix)``)::
|
2015-07-24 08:49:17 -06:00
|
|
|
|
|
|
|
export CC=/usr/local/bin/gcc-4.5
|
|
|
|
export CXX=/usr/local/bin/g++-4.5
|
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
Macports::
|
2012-10-20 07:06:33 -06:00
|
|
|
|
|
|
|
export CC=/opt/local/bin/gcc-mp-4.5
|
|
|
|
export CXX=/opt/local/bin/g++-mp-4.5
|
2014-02-24 15:46:08 -07:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
#. Build dfhack::
|
2012-10-20 07:06:33 -06:00
|
|
|
|
|
|
|
mkdir build-osx
|
|
|
|
cd build-osx
|
|
|
|
cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/path/to/DF/directory
|
|
|
|
make
|
|
|
|
make install
|
2012-10-16 13:58:34 -06:00
|
|
|
|
2013-03-14 12:42:15 -06:00
|
|
|
|
2012-02-24 12:25:53 -07:00
|
|
|
Windows
|
|
|
|
=======
|
2012-02-24 12:28:17 -07:00
|
|
|
On Windows, DFHack replaces the SDL library distributed with DF.
|
2012-02-24 12:25:53 -07:00
|
|
|
|
|
|
|
Dependencies
|
2015-11-05 03:40:09 -07:00
|
|
|
------------
|
2015-11-05 22:58:58 -07:00
|
|
|
You will need some sort of Windows port of git, or a GUI. Some examples:
|
2010-07-19 21:27:12 -06:00
|
|
|
|
2015-11-05 22:58:58 -07:00
|
|
|
* `Git for Windows <https://git-for-windows.github.io>`_ (command-line and GUI)
|
|
|
|
* `tortoisegit <https://tortoisegit.org>`_ (GUI and File Explorer integration)
|
|
|
|
|
|
|
|
You need ``cmake``. Get the win32 installer version from
|
|
|
|
`the official site <http://www.cmake.org/cmake/resources/software.html>`_.
|
2011-07-30 21:50:37 -06:00
|
|
|
It has the usual installer wizard. Make sure you let it add its binary folder
|
|
|
|
to your binary search PATH so the tool can be later run from anywhere.
|
2010-07-19 21:27:12 -06:00
|
|
|
|
2011-12-24 06:44:14 -07:00
|
|
|
You'll need a copy of Microsoft Visual C++ 2010. The Express version is sufficient.
|
2015-11-07 14:48:00 -07:00
|
|
|
Grab it from `Microsoft's site <http://download.microsoft.com/download/1/E/5/1E5F1C0A-0D5B-426A-A603-1798B951DDAE/VS2010Express1.iso>`_.
|
|
|
|
You'll also need the Visual Studio 2010 SP1 update.
|
2013-12-24 06:08:39 -07:00
|
|
|
|
2015-09-24 04:17:58 -06:00
|
|
|
For the code generation parts, you'll need perl with XML::LibXML and XML::LibXSLT.
|
2015-11-07 15:18:50 -07:00
|
|
|
`Strawberry Perl <http://strawberryperl.com>`_ works nicely for this and includes
|
|
|
|
all of the required packages.
|
2011-12-24 06:44:14 -07:00
|
|
|
|
2015-09-24 04:17:58 -06:00
|
|
|
If you already have a different version of perl (for example the one from cygwin),
|
|
|
|
you can run into some trouble. Either remove the other perl install from PATH, or
|
2015-11-07 15:18:50 -07:00
|
|
|
install libxml and libxslt for it instead.
|
2012-02-04 20:28:20 -07:00
|
|
|
|
2011-07-30 21:50:37 -06:00
|
|
|
Build
|
2015-11-05 03:40:09 -07:00
|
|
|
-----
|
|
|
|
There are several different batch files in the ``build`` folder along
|
|
|
|
with a script that's used for picking the DF path.
|
2012-02-04 20:28:20 -07:00
|
|
|
|
2015-11-06 17:35:44 -07:00
|
|
|
First, run ``set_df_path.vbs`` and point the dialog that pops up at your
|
2015-11-05 03:40:09 -07:00
|
|
|
DF folder that you want to use for development.
|
2012-02-04 20:28:20 -07:00
|
|
|
Next, run one of the scripts with ``generate`` prefix. These create the MSVC solution file(s):
|
|
|
|
|
|
|
|
* ``all`` will create a solution with everything enabled (and the kitchen sink).
|
2015-11-05 03:40:09 -07:00
|
|
|
* ``gui`` will pop up the cmake gui and let you pick and choose what to build.
|
|
|
|
This is probably what you want most of the time. Set the options you are interested
|
|
|
|
in, then hit configure, then generate. More options can appear after the configure step.
|
|
|
|
* ``minimal`` will create a minimal solution with just the bare necessities -
|
|
|
|
the main library and standard plugins.
|
2010-07-19 21:27:12 -06:00
|
|
|
|
2012-02-04 20:28:20 -07:00
|
|
|
Then you can either open the solution with MSVC or use one of the msbuild scripts:
|
2010-07-19 21:27:12 -06:00
|
|
|
|
2015-11-05 03:40:09 -07:00
|
|
|
* Scripts with ``build`` prefix will only build DFHack.
|
2012-02-04 20:28:20 -07:00
|
|
|
* Scripts with ``install`` prefix will build DFHack and install it to the previously selected DF path.
|
|
|
|
* Scripts with ``package`` prefix will build and create a .zip package of DFHack.
|
|
|
|
|
|
|
|
When you open the solution in MSVC, make sure you never use the Debug builds. Those aren't
|
2011-07-30 21:50:37 -06:00
|
|
|
binary-compatible with DF. If you try to use a debug build with DF, you'll only get crashes.
|
2015-11-05 03:40:09 -07:00
|
|
|
For this reason the Windows "debug" scripts actually do RelWithDebInfo builds,
|
|
|
|
so pick either Release or RelWithDebInfo build and build the INSTALL target.
|
|
|
|
|