building on cygwin

1,032 views
Skip to first unread message

Anton Vodonosov

unread,
Aug 11, 2012, 4:03:34 PM8/11/12
to ledge...@googlegroups.com
I've just cloned the gitub ledger repo.

Running ./acprep udpate on cygwin results in:

$ ./acprep update
acprep: INFO: Invoking primary phase: update
acprep: INFO: Executing phase: update
acprep: INFO: Executing phase: pull
Traceback (most recent call last):
  File "/usr/lib/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 436, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.6/logging/__init__.py", line 306, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting


I would appreciate advice how to finish the build

John Wiegley

unread,
Aug 11, 2012, 7:16:55 PM8/11/12
to ledge...@googlegroups.com
I've never seen this before. Please try running with acprep --debug.

John

Anton Vodonosov

unread,
Aug 12, 2012, 4:28:42 PM8/12/12
to ledge...@googlegroups.com, jo...@newartisans.com
OK, that was git absent from cygwin PATH.

After fixing this and installing all the dependencies I stopped at the following:

acprep: INFO: System type is => CYGWIN_NT-6.1-WOW64
acprep: INFO: Setting up build flavor => debug
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/c/Users/anton/projects/ledger/bui
ld/ledger/debug
[  1%] Generating ../system.hh.gch
Scanning dependencies of target libledger
[  3%] Building CXX object src/CMakeFiles/libledger.dir/stats.cc.o
In file included from /cygdrive/c/Users/anton/projects/ledger/src/stats.cc:38:0:

/cygdrive/c/Users/anton/projects/ledger/src/report.h: In constructor 'ledger::report_t::pager_option_t::pager_option_t()':
/cygdrive/c/Users/anton/projects/ledger/src/report.h:788:3: error: 'setenv' wasnot declared in this scope
src/CMakeFiles/libledger.dir/build.make:54: recipe for target `src/CMakeFiles/libledger.dir/stats.cc.o' failed
make[2]: *** [src/CMakeFiles/libledger.dir/stats.cc.o] Error 1
CMakeFiles/Makefile2:112: recipe for target `src/CMakeFiles/libledger.dir/all' failed
make[1]: *** [src/CMakeFiles/libledger.dir/all] Error 2
Makefile:143: recipe for target `all' failed
make: *** [all] Error 2
acprep: ERROR: Execution failed: make

Anton Vodonosov

unread,
Aug 12, 2012, 5:26:07 PM8/12/12
to ledge...@googlegroups.com, jo...@newartisans.com
The "setenv" in question is in the report.h, line 800.

I noticed std::getenv few lines above and decided to try std::setenv :)

Doesn't work - it says "setenv is not a member of std".
I haven't programmed in C++ for maybe 6 years, so I don't know.

Just commented out the setenv call. Compilation proceeded with
two warnings and finally stopped with error:


[ 38%] Building CXX object src/CMakeFiles/libledger.dir/textual.cc.o
In file included from /cygdrive/c/Users/anton/projects/ledger/src/textual.cc:41:
0:
/cygdrive/c/Users/anton/projects/ledger/src/pstream.h: In member function 'virtu
al std::basic_streambuf<char>::pos_type ptristream::ptrinbuf::seekoff(std::basic
_streambuf<char, std::char_traits<char> >::off_type, std::ios_base::seekdir, std
::ios_base::openmode)':
/cygdrive/c/Users/anton/projects/ledger/src/pstream.h:86:14: warning: enumeratio
n value '_S_ios_seekdir_end' not handled in switch




[ 52%] Building CXX object src/CMakeFiles/libledger.dir/format.cc.o
In file included from /cygdrive/c/Users/anton/projects/ledger/src/format.cc:36:0
:
/cygdrive/c/Users/anton/projects/ledger/src/pstream.h: In member function 'virtu
al std::basic_streambuf<char>::pos_type ptristream::ptrinbuf::seekoff(std::basic
_streambuf<char, std::char_traits<char> >::off_type, std::ios_base::seekdir, std
::ios_base::openmode)':
/cygdrive/c/Users/anton/projects/ledger/src/pstream.h:86:14: warning: enumeratio
n value '_S_ios_seekdir_end' not handled in switch



[ 67%] Building CXX object src/CMakeFiles/libledger.dir/quotes.cc.o
/cygdrive/c/Users/anton/projects/ledger/src/quotes.cc: In function 'boost::optio
nal<ledger::price_point_t> ledger::commodity_quote_from_script(ledger::commodity
_t&, const ledger::commodity_t*)':
/cygdrive/c/Users/anton/projects/ledger/src/quotes.cc:66:50: error: 'popen' was
not declared in this scope
/cygdrive/c/Users/anton/projects/ledger/src/quotes.cc:69:18: error: 'pclose' was

 not declared in this scope
src/CMakeFiles/libledger.dir/build.make:951: recipe for target `src/CMakeFiles/l
ibledger.dir/quotes.cc.o' failed
make[2]: *** [src/CMakeFiles/libledger.dir/quotes.cc.o] Error 1

Anton Vodonosov

unread,
Aug 12, 2012, 6:22:51 PM8/12/12
to ledge...@googlegroups.com, jo...@newartisans.com
After changing

#ifndef WIN32

to

#if 0

at the quotes.cc, line 65 the compilation proceeded until:

[ 15%] Building CXX object src/CMakeFiles/libledger.dir/times.cc.o
/cygdrive/c/Users/anton/projects/ledger/src/times.cc: In member function 'T ledg
er::<unnamed>::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const ch
ar*) [with T = boost::posix_time::ptime, InputFacetType = boost::date_time::time
_input_facet<boost::posix_time::ptime, char>, OutputFacetType = boost::date_time
::time_facet<boost::posix_time::ptime, char>]':
/cygdrive/c/Users/anton/projects/ledger/src/times.cc:141:45: error: 'strptime' w
as not declared in this scope
/cygdrive/c/Users/anton/projects/ledger/src/times.cc: In member function 'T ledg
er::<unnamed>::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const ch
ar*) [with T = boost::gregorian::date, InputFacetType = boost::date_time::date_i
nput_facet<boost::gregorian::date, char>, OutputFacetType = boost::date_time::da
te_facet<boost::gregorian::date, char>]':
/cygdrive/c/Users/anton/projects/ledger/src/times.cc:178:45: error: 'strptime' w
as not declared in this scope
/cygdrive/c/Users/anton/projects/ledger/src/times.cc:183:3: warning: control rea
ches end of non-void function
/cygdrive/c/Users/anton/projects/ledger/src/times.cc: In member function 'T ledg
er::<unnamed>::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const ch
ar*) [with T = boost::posix_time::ptime, InputFacetType = boost::date_time::time
_input_facet<boost::posix_time::ptime, char>, OutputFacetType = boost::date_time
::time_facet<boost::posix_time::ptime, char>]':
/cygdrive/c/Users/anton/projects/ledger/src/times.cc:146:3: warning: control rea
ches end of non-void function
src/CMakeFiles/libledger.dir/build.make:1135: recipe for target `src/CMakeFiles/
libledger.dir/times.cc.o' failed
make[2]: *** [src/CMakeFiles/libledger.dir/times.cc.o] Error 1

CMakeFiles/Makefile2:112: recipe for target `src/CMakeFiles/libledger.dir/all' f
ailed
make[1]: *** [src/CMakeFiles/libledger.dir/all] Error 2
Makefile:143: recipe for target `all' failed
make: *** [all] Error 2
acprep: ERROR: Execution failed: make





I am not sure what to do. Commenting time parsing doesn't seem to be reasonable approach - Ledger will become not functional without times.
Specify USE_BOOST_FACETS? How? Or maybe cygwing has strptime in a different headers than other systems? I don't know.

Max Erickson

unread,
Aug 13, 2012, 7:19:19 AM8/13/12
to ledge...@googlegroups.com, jo...@newartisans.com
Hi-

I successfully built ledger 3 on cygwin back in April, before the changeover to CMake. I put the exe and (I think all) the necessary dlls up here: http://dl.dropbox.com/u/1925545/ledger3-cygwin-201204.zip . I'm prepared to say that it works for me, but that's about it.

With the old build system, compiling with Cygwin pretty much just worked; I wonder if CMake is targeting win32, when it maybe should be targeting Cygwin.


Max

Anton Vodonosov

unread,
Aug 13, 2012, 8:33:58 AM8/13/12
to ledge...@googlegroups.com, jo...@newartisans.com
Max, thanks for the binaries.

When I run your ledger.exe from cygwin bash, it works.

But when I run it from Windows command line directly, without starting bash, it crashes:

>C:\Users\anton\unpacked\ledger\ledger3-cygwin-201204\ledger.exe

Exception during initialization: locale::facet::_S_create_c_locale name not valid
      1 [main] ledger 7960 exception::handle: Exception: STATUS_ACCESS_VIOLATION
   2433 [main] ledger 7960 open_stackdumpfile: Dumping stack trace to ledger.exe.stackdump

Can you advice how to workaround this issue with locales?

Best regards,
- Anton

Max Erickson

unread,
Aug 13, 2012, 12:44:21 PM8/13/12
to ledge...@googlegroups.com

Hi Anton-

Do you have LANG or other locale related environment variables set? I had some issues with locale related crashes but stopped looking into it after I found that setting LANG = "" worked around them (my Windows environment doesn't have LANG set, I had to do this to get things working under Cygwin bash...).

Max

Anton Vodonosov

unread,
Aug 13, 2012, 2:20:07 PM8/13/12
to ledge...@googlegroups.com, Max Erickson
I've tried to experiment with LANG values but it doesn't help.

Do you have debug version of the binaries? It would be interesting to see the stack trace

Max Erickson

unread,
Aug 13, 2012, 3:43:09 PM8/13/12
to ledge...@googlegroups.com


On Monday, August 13, 2012 2:20:07 PM UTC-4, Anton Vodonosov wrote:
I've tried to experiment with LANG values but it doesn't help.

Do you have debug version of the binaries? It would be interesting to see the stack trace

Here's what I have:

http://dl.dropbox.com/u/1925545/ledger-cygwin-with-symbols-201204.zip

I guess that the first exe I uploaded is just the stripped version of this one, but I don't remember particularly clearly.


Max

Anton Vodonosov

unread,
Aug 13, 2012, 6:25:50 PM8/13/12
to ledge...@googlegroups.com, Max Erickson
ledger.exe.stackdump file produced by this version also doesn't contain stacktrace.

Ok, so I am limited to starting bash before using ledger. It's better than starting a
separate virtual machine. I think I can live with this. Thanks again for the binary.

As a bottom line of the locale-related crash. It is strange.

According to the Cygwin docs - http://cygwin.com/cygwin-ug-net/setup-env.html -
cygwin processes import all the windows environment variables

When I run the "locale" command, it prints the follwoing

LANG=enu
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

I have set all these Cygwin variables to the same values on windows,
so that result is the same both when I run locale from windows command
line and from cygwin bash.

Still, the crash happens.

Best regards,
- Anton

Anton Vodonosov

unread,
Aug 14, 2012, 12:03:36 PM8/14/12
to ledge...@googlegroups.com, Max Erickson
Max, I only now understood what you mean.

So, _without_ any locale related variables ledger works for you (in particular in windows command line),
while _with_ locale variables it crashes (in bash).

I have just carefully deleted all the locale related variables from Windows settings and ledger works for
me without cygwin bash!

Thanks.


- Anton

Maksym Satula

unread,
Jan 23, 2014, 5:45:51 PM1/23/14
to ledge...@googlegroups.com, Max Erickson
I'm happy you guys were able to run some windows binary built in 2012 =)
However, the problem is still open, I believe.

I have a warning here:

acprep: INFO: Executing phase: submodule
/usr/lib/git-core/git.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

Not sure which library is missing and how to check it.

And errors discussed earlier, i.e.
1. Call of setenv in src/report.h, which can be simply commented out
and
2.
src/quotes.cc:66:50: error: ‘popen’ was not declared in this scope
src/quotes.cc:69:18: error: ‘pclose’ was not declared in this scope

Anybody, who still did not loose interest in that, any help please?

Daniel Martins

unread,
May 27, 2014, 11:23:26 AM5/27/14
to ledge...@googlegroups.com
I'm sorry for digging up this matter.
I've managed to build ledger on cygwin just now. Here are the steps I've taken, just in case anybody is interested:

  • On reports.h
    • Comment lines #791 to #808
    • Comment line #810
  • On quotes.cc
    • On line #65, replace #ifndef WIN32 with #if 0
  • On times.cc
    • Comment lines #36 and #38
  • On strptime.cc
    • Comment lines #16 and #189
    • Replace every single occurrence of strnicmp by strncasecmp
    • Add #include <strings.h>
Hope this helps! ;)

Anton Vodonosov

unread,
May 27, 2014, 2:34:52 PM5/27/14
to ledge...@googlegroups.com
Thanks, it may be useful for me in the future.
 
To make your recipe more reproducible, could you specify exact version (git revision)
of your ledger source code?
 
Or even better, commit it into your fork of ledger-cli on github,
so that anyone can just clone it.
 
Best regards,
- Anton
 
27.05.2014, 22:29, "Daniel Martins" <gdaniel...@gmail.com>:

Jostein Berntsen

unread,
Jun 2, 2014, 6:49:51 AM6/2/14
to ledge...@googlegroups.com

This looks interesting, did look into some of these files previously, but did not try all this out. I had a hard time getting ledger installed in cygwin, but found out this worked for me:

Update CMakeLists.txt with this:

add_definitions(-std=c++11 -U__STRICT_ANSI__)

Then you can run "./acprep --python update" and it gets installed. It does not link up the ledger.exe files in /usr/bin correctly with the libledger-3.dll thought so I had to do that manually.

 Jostein

Maksym Satula

unread,
Jul 9, 2014, 10:14:43 AM7/9/14
to ledge...@googlegroups.com

Thank you Daniel for your response. Actually, I have also tried to adjust C code to make it compilable, but after changing 2 or 3 source files I said myself "stop" and gave up. By some reason, I did not like the idea to amputate some (even small) pieces of functionality just to obtain some "non-vanilla" executable by any cost.

Thank you Jostein, it worked for me! I've got ledger.exe without any extra steps. This is still a plan B for me, and my next goal is to have a native Windows binary compiled with MSVC 12 (VS 2013), which is much trickier. But that is not a topic for this thread.

All the best!
Max
Message has been deleted
Message has been deleted

Anton Vodonosov

unread,
Jul 9, 2014, 10:22:59 AM7/9/14
to ledge...@googlegroups.com
On Wednesday, July 9, 2014 5:14:43 PM UTC+3, Maksym Satula wrote:
This is still a plan B for me, and my next goal is to have a native Windows binary compiled with MSVC 12 (VS 2013), which is much trickier. But that is not a topic for this thread.

Please don't forget to share your results on this group
 

Maksym Satula

unread,
Jul 11, 2014, 12:15:29 PM7/11/14
to ledge...@googlegroups.com
Hi Anton,

You know, after having a second thought, maybe it does not make much sense to have it compiled under Windows natively.
I was unable to find any Windows console function calls in the source code (such as SetConsoleTextAttribute). And, as far as I can see from report.cc, all colors are made by ANSI ESC sequences not wrapped into any platform #ifdefs, but ESC sequences do not work with pure Windows Console (unless something such as ANSICON installed).
That means if Windows build succeeds, there will be no colorful output out-of-the-box.

Unless I find some time to contribute (or anybody else does) to the project and add some pieces #ifdef WIN32 ... SetConsoleTextAttribute ... #endif, I do not see spending time to compile it natively for Windows reasonable.

IMHO, it is better to bother installing Cygwin, than to (1) do a bunch of tricks during compilation (2a) still have black&white output or (2b) still install a "dependency" ANSICON.


And yes, Cygwin bash shell has functions to make the life easier.
One make write something like this in some bash script:

function bal {
        ledger -sVc bal $@
}

function reg {
        ledger --tail 20 -S d -w reg $@
}

To have a similar effect, I had to create a separate *.cmd files for each function.

Anton Vodonosov

unread,
Jul 11, 2014, 1:36:27 PM7/11/14
to ledge...@googlegroups.com
Maksym,
 
Very reasonable, I agree.
Cygwin is easy to install.
 
Then, if any Windows user has spare time, it's better to spend it on
making sure cygwind build works OK.
 
In particular, convincing maintainer to commit the fix described in this thread:
 
 
Jostein Berntse:

Dwan 765

unread,
Aug 10, 2020, 12:53:37 PM8/10/20
to Ledger
Does anyone have to make Ledger3 available for WindowsXP in Cygwin? I need it urgently and I can't compile, whenever I try to get this error:

[ 70%] Building CXX object src/CMakeFiles/libledger.dir/amount.cc.o

[ 71%] Building CXX object src/CMakeFiles/libledger.dir/stream.cc.o
[ 73%] Building CXX object src/CMakeFiles/libledger.dir/mask.cc.o
[ 75%] Building CXX object src/CMakeFiles/libledger.dir/times.cc.o
/home/0wner/ledger-3.1.1/src/times.cc: In member function ‘T ledger::{anonymous}::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const char*) [with T = boost::posix_time::ptime; InputFacetType = boost::date_time::time_input_facet<boost::posix_time::ptime, char>; OutputFacetType = boost::date_time::time_facet<boost::posix_time::ptime, char>]’:
/home/0wner/ledger-3.1.1/src/times.cc:145:45: error: ‘strptime’ was not declared in this scope
if (strptime(str, fmt_str.c_str(), &data))
^
/home/0wner/ledger-3.1.1/src/times.cc: In member function ‘T ledger::{anonymous}::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const char*) [with T = boost::gregorian::date; InputFacetType = boost::date_time::date_input_facet<boost::gregorian::date, char>; OutputFacetType = boost::date_time::date_facet<boost::gregorian::date, char>]’:
/home/0wner/ledger-3.1.1/src/times.cc:182:45: error: ‘strptime’ was not declared in this scope
if (strptime(str, fmt_str.c_str(), &data))
^
/home/0wner/ledger-3.1.1/src/times.cc: In member function ‘T ledger::{anonymous}::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const char*) [with T = boost::posix_time::ptime; InputFacetType = boost::date_time::time_input_facet<boost::posix_time::ptime, char>; OutputFacetType = boost::date_time::time_facet<boost::posix_time::ptime, char>]’:
/home/0wner/ledger-3.1.1/src/times.cc:150:3: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/0wner/ledger-3.1.1/src/times.cc: In member function ‘T ledger::{anonymous}::temporal_io_t<T, InputFacetType, OutputFacetType>::parse(const char*) [with T = boost::gregorian::date; InputFacetType = boost::date_time::date_input_facet<boost::gregorian::date, char>; OutputFacetType = boost::date_time::date_facet<boost::gregorian::date, char>]’:
/home/0wner/ledger-3.1.1/src/times.cc:187:3: warning: control reaches end of non-void function [-Wreturn-type]
}
^
make[2]: *** [src/CMakeFiles/libledger.dir/build.make:1172: src/CMakeFiles/libledger.dir/times.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:125: src/CMakeFiles/libledger.dir/all] Error 2
make: *** [Makefile:161: all] Error 2


acprep: ERROR: Execution failed: make



What I'm doing wrong? Help me please!!


Reply all
Reply to author
Forward
0 new messages