Skip to content

DFLib prerequisites and building

Tom Russo edited this page Apr 28, 2015 · 9 revisions

The process of building DFLib involves a few steps:

  1. Install all prerequisite libraries and tools from your package management system or from source.
  2. If you are not installing from a "release" tarball, you must "bootstrap" the source code to create the "configure" script.
  3. Create a build directory and configure DFLib
  4. Build DFLib.

Install prerequisite packages

DFLib depends on only a few basic tools and packages:

  1. A modern C++ compiler, such as GCC or Clang
  2. Autoconf, automake, and libtool for the standard build. DFLib comes with files so that CMake can be used instead, but this is a recent, experimental feature.
  3. The cartographic projection library, proj.4.

These packages should be available on any package management system for Unix-like operating systems, or Windows using Cygwin. It is possible to build DFLib on Windows without the Cygwin environment, but we won't document that here (yet).

Install these packages before attempting to build DFLib.

Bootstrap the source code

In the top-level directory of the source code, run the "bootstrap.sh" script: ./bootstrap.sh This will create the configure script that you use to configure DFLib for your system.

Create a build directory and configure DFLib

The recommended procedure for building DFLib is to perform an "out-of-source" build --- that is, build the code in a directory other than the directory that contains the source code. This keeps your source tree clean, and allows you to do multiple builds out of the same source tree (e.g. using a shared folder of source code to build the program on multiple platforms, or with different build options or compilers).

The process is:

  1. Create an empty directory and "cd" into it.
  2. Run the "configure" script for DFLib using the complete path to the script, adding options necessary to help configure find dependent libraries.
  3. run "make" to build the code
  4. optionally, run "sudo make install" to install the code in a central location.

It is not absolutely necessary to install DFLib unless you want to. You can leave the uninstalled code in place and link to it from other programs using compiler and linker options if you like. But installing the library is the easiest way to let it be accessible to other programs, such as the companion qDF GUI software.

If DFLib's source code resides in your "~/src/DFLib" directory, the entire process would look like this on Linux:

mkdir ~/DFLib_Build
cd ~/DFLib_Build
~/src/DFLib/configure
make
sudo make install

System-specific hints

Linux

There are no real gotchas to installing on Linux. Most Linux package managers install libraries into /usr/lib and headers into /usr/include, so configure will just find them. You will have to make sure to install the "development" package for proj.4, which contains the static library and headers you need to build DFLib and its demo programs.

Mac OS X

Building DFLib on OS X generally requires that you also install some sort of package management system. The author recommends Homebrew, and has tested this process using that package manager.

First, install XCode. This is done on OS X Mavericks and later simply by executing xcode-select --install.

Install Homebrew according to its web site directions, then issue the following commands in a terminal window to install prerequisites:

brew install proj

FreeBSD

Install the "graphics/proj" port, the "devel/autoconf" port and the "devel/automake" ports.

Since FreeBSD ports install into /usr/local instead of /usr, you'll need to add options to configure in order ,to allow it to find the libraries and headers.

mkdir ~/DFLib_Build
cd ~/DFLib_Build
~/src/DFLib/configure CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
make
sudo make install

Windows

The author hates Windows and regrets ever having mentioned it. But DFLib can be built here. For the moment, I recommend just using Cygwin, and pretending you're on Linux. All of the packages DFLib and qDF requires should be available under the Cygwin package system, and building under Cygwin is no different from building under Linux.

However, I have also built DFLib (and even the companion GUI, qDF) on Windows using Microsoft Visual Studio Express. Doing so requires building proj.4 from source, and using CMake instead of autoconf. When I did it, qDF even required building the Qt 4 framework from source as well. There are some hints about how to do it in the "INSTALL_CMake" file included with the source code. If you are comfortable enough with Visual Studio and CMake to be willing to try this, those hints are probably enough to get you going.

If you're uncomfortable with building C++ codes on Windows and just want to download and use DFLib/qDF without having to compile it yourself, you're out of luck.