Building with Cygwin, revisited

375 views
Skip to first unread message

Tim Crews

unread,
Jan 20, 2013, 12:42:50 PM1/20/13
to ledge...@googlegroups.com
Hello,

I am currently stuck spending most of my time in a Windows environment, so I find myself wanting an up-to-date Ledger 3 build.  I saw previous discussions about building with Cygwin.  It appears that the last time Ledger 3 was successfully built with Cygwin was before the conversion to CMake.  Someone tried to build using the new CMake system back in August 2012, but there is no record that they succeeded.  So I am trying it now.

I'm stuck at a fairly early step, probably because I don't know much about CMake.  When I run
    .acprep config
the CMake system tries to launch the Visual Studio 10 compiler, for which I do not have a license.  (I have a valid 2012 license, though.)  It does not try any other compilers.

I have the Gnu C and C++ compilers installed under Cygwin, so I have tried

git clean -dfx
export CMAKE_CXX_COMPILER="g++"
export CMAKE_C_COMPILER="gcc"
./acprep config

but it still tried to launch the Visual Studio 2010 compiler.

How do I get it to use the Gnu compiler?

Thanks,
Tim Crews


John Wiegley

unread,
Jan 20, 2013, 5:38:08 PM1/20/13
to ledge...@googlegroups.com
>>>>> Tim Crews <t...@code-affinity.com> writes:

> How do I get it to use the Gnu compiler?

cmake -G make ..., in addition to what you're doing.

John

John Wiegley

unread,
Jan 20, 2013, 5:38:08 PM1/20/13
to ledge...@googlegroups.com
>>>>> Tim Crews <t...@code-affinity.com> writes:

> How do I get it to use the Gnu compiler?

Tim Crews

unread,
Jan 21, 2013, 12:01:53 PM1/21/13
to ledge...@googlegroups.com, jo...@newartisans.com
I was able to get a working Cygwin build of ledger 3 built from git master on my 64-bit Windows 7 machine.

Steps:

Using Cygwin setup, install the following packages:  libboost-devel, gmp, mpfr, gettext, libedit, python, doxygen, texinfo, cmake, gcc.

I was not able to find the following packages stock from Cygwin, so I just skipped them:  graphvis, lcov, sloccount

When setup was completed, I ran into the infamous process fork error, requiring a "rebaseall" to fix.  See http://cygwin.wikia.com/wiki/Rebaseall

If you have a Win32 version of CMake installed in addition to Cygwin cmake, make sure that the Win32 Cmake is not on your path at all.  It is not enough to ensure that the Cygwin cmake is first on the path.  I ran into this.  Even though "which cmake" from the Cygwin shell responded with the expected "/usr/bin/cmake", when I actually ran the CMake I found that it was somehow running the Win32 Cmake.  The Win32 Cmake uses different path defaults for finding packages, and it will not work to build ledger.  Debugging this was the most time-consuming part of this whole process.

The Cygwin packaging of boost is strange.  Cygwin setup makes a distinction between installing the binaries and installing the source for each package.  Of course, boost is mostly source code.  The current Cygwin package directory has boost 1.46.1 and 1.48.  I was unable to get it to install the boost headers for 1.46.1 with any combination of "binary" and "source" installation options.  I eventually just installed libboost-devel, which installed the headers for boost 1.48.  I had to modify CMakeLists.txt to specify 1.48 instead of 1.46.

From a Cygwin prompt at the top level ledger directory, run
   
    cmake -G "Unix Makefiles" .

Strangely, I had to repeat this a few times before it succeeded.  I didn't take detailed notes at this point, but I'm sure it failed a few times not being able to find mpfr and gmp, but then it eventually found them even though I had already installed them before I ran cmake for the first time.  The Win32 cmake conflict may have caused this. 

Finally:

   ./acprep update

and ledger built without any further difficulties.  When I ran the resulting executable, I got yet another Cygwin process fork error.  I had to do another Cygwin rebaseall; I suppose this remapped the load address for libledger.

As other people have already described, when I ran ledger I got a segfault with the error "Exception during initialization: locale::facet::_S_create_locale name not valid".  I set LANG to "" and that problem went away, i.e.:

    export LANG=""
    ledger bal

This produced the desired ledger balance report.  That's all I've tried so far.

Tim Crews

Anton Vodonosov

unread,
Mar 1, 2013, 5:50:44 PM3/1/13
to ledge...@googlegroups.com, jo...@newartisans.com
Thanks for this post. I finally managed to build leger on cygwin (previously on this list I reported compilation error due to undefined function setenv,
but I think it was caused either by old cygwin, or by mingw present in my path).

Now that I can build ledger, I hope I will be to customize it to my needs (balancing currencies), and who knows, maybe even contributing some code.
Reply all
Reply to author
Forward
0 new messages