Build instructions for Cygwin

praxiq edited this page Sep 19, 2016 · 6 revisions

UPDATE: September 2016: The instructions shown here are obsolete and do not work as presented. See the bug report for a small patch that will allow the process below to succeed. As explained in the bug report, Ledger built in this way will not pass all of its tests. Whether it may return incorrect information in a real-world setting is unknown.

Given these issues, users with the latest version of Windows 10 have an alternative to cygwin. Install the Windows Subsystem for Linux and then simply follow the installation instructions for Ubuntu, namely:

$ sudo apt-get install git
$ git clone git://github.com/ledger/ledger.git
$ cd ledger 
$ git checkout -b master origin/master  # Gives you the latest stable version - skip for the bleeding-edge version
$ ./acprep dependencies
$ ./acprep update

Introduction

It is actually not very hard to get ledger built under Cygwin (a Unix-like environment that runs under Microsoft Windows.) For the most part, the process is as simple as cloning ledger, installing dependent packages, and then using the ledger acprep utility to build and install ledger.

These notes were initially prepared in June 2013, when Ledger was at version 3.0 20130529. And adapted after ledgers cmake configuration was adapted 20150104 to install out of the box under cygwin at Ledger version 3.1.

Dependencies

Using the Cygwin setup program, install the following packages, if they are not already installed:

  • git
  • gcc
  • cmake
  • make
  • libboost1.53 (or later, currentl libboost is at 1.55)
  • gmp
  • mpfr
  • gettext
  • libedit
  • python
  • doxygen
  • texinfo

There are no stock packages for graphvis, lcov, or sloccount in the Cygwin package archive, but these are optional dependencies for Ledger. It will build fine without them.

I recall that I had trouble getting CMake to find Boost even after it was installed by Cygwin. If I remember correctly, I also had to check the "Install source" option for the Boost libraries. This makes a little bit of sense, since the Boost libraries consist mainly of source header files.

I also had trouble getting CMake to find gmp and mpfr until I also installed the gmp-devel package. I don't think this should have been necessary, your mileage may vary.

Obtaining Ledger source code

This is as easy as

git clone https://github.com/ledger/ledger.git

First time installation

Run

./acprep gitclean
./acprep config

This is when you will find out if you have all of the dependent libraries installed. This is the most difficult part of the process. CMake (which is called by the ./acprep config) can be finicky. If this step is not succesful and still some dependencies are missing, then go back to Cygwin setup, install missing packages, and repeat above steps until config is succesful and all necessary dependencies are found.

If all is well run

./acprep update

If you have a processor with multiple cores, you might want to pass a -jX option, where X is the number of cores you want it to use for compiling. You don't get to see 100% CPU utilization very often -- here's your chance.

If all went well, the result will be a file named ledger.exe at the top of your source tree.

Finally, you can install ledger to the standard location by running

make install

This will put ledger in /usr/local/bin/ledger.

Subsequent installs, get latest software and build it

The following command does it all:

./acprep update

Issues you might run into

Can't find the libledger-3.dll

When ledger is called from a location other then the directory where it was compiled, it can not find the libledger-3.dll. Usually this is installed in /usr/local/lib. Make sure this path is added to the PATH environment variable by editing your .bashrc. This fixes this.

The process fork error

On two occasions when I built Ledger under Cygwin, I encountered a "process fork error". See http://cygwin.wikia.com/wiki/Rebaseall. The solution is to do a "rebase all" as described in that article.

Danger if you also have Windows CMake

If you have the Windows version of CMake installed, the Cygwin CMake may get confused even if the Windows CMake is not on your path! In the middle of running your Cygwin CMake, Windows-style pathnames will start appearing, or CMake will be unable to find things that you are sure are there. To get this to work, I had to temporarily rename my Windows cmake.exe to something else to get it out of the way.

When I repeated this process a few months later, I did not have this problem.

Locale-related error messages

If you get a segfault with the error "Exception during initialization: locale::facet::_S_create_locale name not valid", try setting the LAGN environment variable to "", i.e.:

export LANG=""

I added this to my .profile.

If that language setting does not accurately reflect your actual language, I don't know what the "right" solution is.