Building on Windows from scratch

Geert Janssens janssens-geert at
Fri Dec 27 12:57:05 EST 2013

On Friday 27 December 2013 08:30:34 Gary Bilkus wrote:
> > > A bit further now.....
> > > 
> > > If I change the REL_REPOS_DIR to $GLOBAL_DIR\\gnucash.git
> > 
> Hi Geert,
> I was indeed running - the version I found in
> packaging/win32 The reference to REL_REPOS_DIR is actuall in
> which is called by
> Specifically, in that file  in the function inst_gnucash() around line
> 1281.
Ok, I remember why I didn't find it. I still have some uncommitted changes in my local 
repository from my struggle with -no-undefined.
One of the changes was to change REL_REPOS_DIR to REPOS_DIR (and _REL_REPOS_UDIR to 

I don't see why we would need to use a relative directory path here.

> Anyway, I've made some more progress. The -no-undefined problem is
> caused because more recent versions of gcc apparently don't understand
> that flag, and don't ignore it but just fail. So although you need to
> pass it to libtool, you mustn't pass it direct to gcc.any more.
> Unfortunately, that means that adding -no-undefined to LDFLAGS causes
> lots of the tests in configure to go wrong with compilation errors,
> and it just happens that the libxml one is the first which is
> mandatory.
> I did a very kludgy workaround by removing -no-undefined from
>, running configure, and then running a script to add
> -no-undefined back into every resulting Makefile. I imagine there's a
> cleaner fix somewhere to put the flag into libtool only, but I haven't
> yet found it.
My attempt to get around this was to add "-no-undefined" to AM_LDFLAGS, which fixed 
configure, but I remember the build was still not compiling correctly. So I manually added -no-
undefined in the qof makefile to libgnc_qof_la_LDFLAGS
If I remember well that got me a bit further before failing again. At which point I refocussed on 
polishing the trunk branch for the upcoming 2.6 release and left the windows fixes for later.

> Anyway, when you do that, it starts to compile the app, and the next
> problem is that some of the code files fail to compile.
> Specifically:
> libqof/qof/guid.c  and backend/xml/sixtp-utils.c
> both fail with compiler warnings about %llu formats  in strings. There
> appears to be a bug in the version of gcc (4.8.1) as downloaded for
> mingw cd . which treats these formats as invalid
> even though they aren't. Then because -Werror is set, the compile
> fails. The solution for the moment was to edit the Makefile to remove
> the -Wall from those files. They then recompile happily.
Nice you got it to compile !

With my local modifications I got stuck in engine/test with this error:
/bin/sh ../../../libtool --tag=CC   --mode=link gcc -I. -I/c/soft/gnucash.git/src/engine/test -I../../.. -
I/c/soft/gnucash.git/src/engine/ -DTESTPROG=test_engine -mms-bitfields -
Ic:/soft/gnome/include/glib-2.0 -Ic:/soft/gnome/lib/glib-2.0/include   -Werror -Wdeclaration-after-
statement -g  -mms-bitfields -g  -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations  -
Wno-unused -no-undefined -L/c/soft/regex/lib -lregex -L/c/soft/gnome/lib -L/c/soft/guile/lib -
L/c/soft/libdbi/lib -L/c/soft/gwenhywfar/lib -L/c/GCDevel/GC-Maint/hh/lib -L/c/soft/sqlite3/lib -
L/c/soft/enchant/lib -L/c/soft/libxslt/lib -L/c/soft/mingw/lib -g -o test-engine.exe test_engine-test-
engine.o test_engine-utest-Account.o test_engine-utest-Budget.o test_engine-utest-Invoice.o ../../../src/libqof/qof/ ../../../src/gnc-module/libgnc- ../../../src/test-core/ ../ ../test-core/libgncmod-test- ../../../src/core-utils/ -Lc:/soft/gnome/lib -lgio-2.0 -lgobject-2.0 -
lgthread-2.0 -lgmodule-2.0 -lglib-2.0 -lintl   -lm
libtool: link: gcc -I. -I/c/soft/gnucash.git/src/engine/test -I../../.. -I/c/soft/gnucash.git/src/engine/ -
DTESTPROG=test_engine -mms-bitfields -Ic:/soft/gnome/include/glib-2.0 -
Ic:/soft/gnome/lib/glib-2.0/include -Werror -Wdeclaration-after-statement -g -mms-bitfields -g -
Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wno-unused -g -o .libs/test-
engine.exe test_engine-test-engine.o test_engine-utest-Account.o test_engine-utest-Budget.o 
test_engine-utest-Invoice.o  -L/c/soft/regex/lib -L/c/soft/gnome/lib -L/c/soft/guile/lib -
L/c/soft/libdbi/lib -L/c/soft/gwenhywfar/lib -L/c/GCDevel/GC-Maint/hh/lib -L/c/soft/sqlite3/lib -
L/c/soft/enchant/lib -L/c/soft/libxslt/lib -L/c/soft/mingw/lib ./.libs/libutest-Split.a -
Lc:/soft/gnome/lib -Lc:/soft/guile/lib -L/c/soft/readline/lib ./.libs/libutest-Trans.a 
/c/soft/gnucash/build/src/test-core/.libs/libtest-core.a ../../../src/libqof/qof/.libs/libgnc-qof.dll.a 
../../../src/gnc-module/.libs/libgnc-module.dll.a ../../../src/test-core/.libs/libtest-core.a 
../.libs/libgncmod-engine.a ../test-core/.libs/libgncmod-test-engine.a 
/c/soft/gnucash/build/src/engine/.libs/libgncmod-engine.a /c/soft/gnucash/build/src/gnc-
module/.libs/libgnc-module.dll.a /c/soft/gnucash/build/src/core-utils/.libs/libgnc-core-utils.dll.a 
../../../src/core-utils/.libs/libgnc-core-utils.dll.a c:/soft/guile/lib/libguile.dll.a -lgmp -lws2_32 
/mingw/lib/libltdl.dll.a -lpthread /c/soft/gnucash/build/src/libqof/qof/.libs/libgnc-qof.dll.a -lregex -
lgio-2.0 -lgobject-2.0 -lgthread-2.0 -lgmodule-2.0 -lglib-2.0 /mingw/lib/libintl.dll.a 
/mingw/lib/libiconv.dll.a -pthread -Lc:/soft/gnucash/inst/lib -Lc:/soft/guile/lib -L/mingw/lib
../.libs/libgncmod-engine.a(Transaction.o):Transaction.c:(.data+0x10): multiple definition of 
./.libs/libutest-Trans.a(utest-Transaction.o):utest-Transaction.c:(.data+0x14): first defined here
collect2.exe: error: ld returned 1 exit status

> The only other source file issue is in
> gnome-gnc-split-reg.h
> where we get the error: expected identifier before numeric constant
> DELETE, A bit of trial and error got this to go away by adding
> #undef DELETE
> #undef DUPLICATE
> on line 116, but to be honest I'm not entirely sure what's going on
> here yet.
> After all that, a make followed by make install seems to complete,
> although with lots of
> libtool: link: warning : 'c/soft/mongw/lib/ seems to be
> moved warnings coming up.
As Derek already said: this is a normal warning which you can ignore.

> Unfortunately, after all that, I can't get it to run.
> If I try to start it from /c/soft/gnucash/inst/bin there are lots of
> missing dlls, which all appear to be dotted around in other places.
> If I copy everything into a single directory and try to run I get
> Error: Unspecified fatal error encountered, aborting.....
The problem here is that most of the dependencies are not installed in one single location 
accessible from the Windows path.

This installation scheme has been chosen for the lack of a package management system in 
mingw/Windows. Having each dependency in a separate directory makes it very easy to renew 
a dependency: simply delete the existing directory and run the build again.

There is a way to run gnucash from the install directory though: you have to include all the bin 
directories of all the dependencies in either the Windows or the MSYS PATH variable. The easiest 
is write a simple batch script for this. We used to have one, which I deleted at some point (way 
too early unfortunately).

My intention is to restore the ability to run gnucash directly from the installation directory. I'm 
not sure how though. Instead of requiring a batch file to set up the environment, I'd rather 
figure out a way to better manage the dependencies together in one location. I'm not sure how 
yet. Either leverage the mingw package manager in some way or do improve the installation 
script to be a bit smarter (leverage make install and make uninstall, using the same prefix for all 
dependencies)... That part is still fuzzy.

My longer term goal is even more ambitious: I would like to eventually get to the point where 
you don't need to run for each minor change. But instead use make as it was intended. 
With that I mean: if you change one file in the engine subdirectory a simple make && make 
install in that directory should be all that's needed, not running on the whole project. 
You can achieve this now already by manually tweaking the build environment but I'd like that 
way of working to become the default. should only be run to update dependencies.

More information about the gnucash-devel mailing list