GeographicLib  1.46
Installing GeographicLib
Back to Introduction. Forward to Getting started. Up to Contents.

GeographicLib has been developed under Linux with the g++ compiler (versions 4.0 and later) and under Windows with Visual Studio 2010, 2012, and 2013. Earlier versions were tested also under Visual Studio 2005 and 2008 and under Darwin and Solaris. It should compile on a wide range of other systems. First download either GeographicLib-1.46.tar.gz or (or GeographicLib-1.46-win32.exe or GeographicLib-1.46-win64.exe for binary installation under Windows). Then pick one of the first five options below:

This section documents only how to install the software. If you wish to use GeographicLib to evaluate geoid heights or the earth's gravitational or magnetic fields, then you must also install the relevant data files. See Installing the geoid datasets, Installing the gravity models, and Installing the magnetic field models for instructions.

The first two installation methods use two important techniques which make software maintenance simpler

Installation with cmake

This is the recommended method of installation; however it requires that cmake be installed on your system. This permits GeographicLib to be built either as a shared or a static library on a wide variety of systems. cmake can also determine the capabilities of your system and adjust the compilation of the libraries and examples appropriately.

cmake is available for most computer platforms. On Linux systems cmake will typically one of the standard packages and can be installed by a command like

  yum install cmake 

(executed as root). The minimum version of cmake supported for building GeographicLib is 2.8.4 (which was released on 2011-02-16). (Actually, a few earlier versions will also work for non-Windows platforms.)

On other systems, download a binary installer from click on download, and save and run the appropriate installer. Run the cmake command with no arguments to get help. Other useful tools are ccmake and cmake-gui which offer curses and graphical interfaces to cmake. Building under cmake depends on whether it is targeting an IDE (interactive development environment) or generating Unix-style makefiles. The instructions below have been tested with makefiles and g++ on Linux and with the Visual Studio IDE on Windows. It is known to work also for Visual Studio 12 Express (2013).

Here are the steps to compile and install GeographicLib:

Installation using the autoconfigure tools

The method works on most Unix-like systems including Linux and Mac OS X. Here are the steps to compile and install GeographicLib:

Installation with GNU compiler and Make

This method requires the standard GNU suite of tools, in particular make and g++. This builds a static library and the examples.

Here are the steps to compile and install GeographicLib:

Installation on Windows

This method requires Visual Studio 2008 or 2010. This builds a static library and the utilities. If you have some other version of Visual Studio, use cmake to create the necessary solution file, see Installation with cmake. (cmake is needed to run the tests.)

The Visual Studio 10 solution also contains projects to build NETGeographicLib and the C# example project.

Using a binary installer

Binary installers are available for some platforms


Use this method if you only need to use the GeographicLib utilities. The header files and static and shared versions of library are also provided; these can only be used by Visual Studio 11 2012 (in either release or debug mode). However, if you plan to use the library, it may be advisable to build it with the compiler you are using for your own code using either Installation with cmake or Installation on Windows.

Download and run GeographicLib-1.46-win32.exe or GeographicLib-1.46-win64.exe:

(Note that the default installation folder adheres the the convention given in Installation with cmake.) The start menu will now include links to the documentation for the library and for the utilities (and a link for uninstalling the library). If you ask for your PATH to be modified, it will include C:/pkg-vc11/GeographicLib-1.46/bin where the utilities are installed. The headers and library are installed in the include/GeographicLib and lib folders. The MATLAB interface is installed in the matlab folder. Add this to your path in MATLAB to access this interface. The libraries were built using using Visual Studio 11 2012 in release and debug modes. The utilities were linked against the release-mode shared library.

NETGeographicLib library dlls (release and debug) are included with the binary installers; these are linked against the shared library for GeographicLib.


You can install using Homebrew. Follow the directions on for installing this package manager. Then type

brew install geographiclib 

Now links to GeographicLib are installed under /usr/local.


Some Linux distributions, Fedora, Debian, and Ubuntu, offer GeographicLib as a standard package. Typically these will be one or two versions behind the latest.

Building the library for use with Qt

If Qt is using a standard compiler, then build GeographicLib with that same compiler (and optimization flags) as Qt.

If you are using the mingw compiler on Windows for Qt, then you need to build GeographicLib with mingw. You can accomplish this with cmake under cygwin with, for example,

  export PATH="`cygpath -m c:/QtSDK/mingw/bin`:$PATH"
  mkdir BUILD
  cd BUILD
  cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX=C:/pkg-mingw/GeographicLib ..
  mingw32-make install 

If cmake complains that sh mustn't be in your path, invoke cmake with

  env PATH="$( echo $PATH | tr : '\n' |
  while read d; do test -f "$d/sh.exe" || echo -n "$d:"; done |
  sed 's/:$//' )" \
  cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX=C:/pkg-mingw/GeographicLib ..

Maintainer tasks

Check the code out of git with

  git clone -b master git:// geographiclib

Here the "master" branch is checked out. There are three branches in the git repository:

The autoconf configuration script and the formatted man pages are not checked into master branch of the repository. In order to create the autoconf configuration script, run


in the top level directory. Provided you are running on a system with doxygen, pod2man, and pod2html installed, then you can create the documentation and the man pages by building the system using cmake or configure.

In the case of cmake, you then run

  make dist 

which will copy the man pages from the build directory back into the source tree and package the resulting source tree for distribution as



  make package 

or building PACKAGE in Visual Studio will create a binary installer for GeographicLib. For Windows, this requires in the installation of NSIS. On Windows, you should configure GeographicLib with PACKAGE_DEBUG_LIBS=ON, build both Release and Debug versions of the library and finally build PACKAGE in Release mode. This will get the release and debug versions of the library included in the package. For example, the 64-bit binary installer is created with

  cmake -G "Visual Studio 10 Win64" \
  cmake --build . --config Debug --target ALL_BUILD
  cmake --build . --config Release --target ALL_BUILD
  cmake --build . --config Release --target matlabinterface
  cmake --build . --config Release --target PACKAGE 

With configure, run

  make dist-gzip 

which will create the additional files and packages the results ready for distribution as

Back to Introduction. Forward to Getting started. Up to Contents.