Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: ChaosFox on September 26, 2011, 12:35:30 PM



Title: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: ChaosFox on September 26, 2011, 12:35:30 PM
Greetings once again.  :)

Yesterday I decided the pick the (somewhat daunting) task to compile Bitcoin from source. So, I grabbed my tools, downloaded all the dependencies with the versions indicated in the build-msw.txt file (https://github.com/bitcoin/bitcoin/blob/master/doc/build-msw.txt), used this thread as a reference for the trickier stuff (https://bitcointalk.org/index.php?topic=5851.0;all) (Only changing the versions for the dependencies where it was relevant), compiled them (Screw you, Boost) and then... nada. Here's the output:

Code:
C:\bitcoin-bitcoin-f8937b2\src>mingw32-make bitcoin.exe bitcoind.exe -f makefile
.mingw
g++ -c -mthreads -O2 -w -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DWIN32
-D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL -DBOOST_THREAD_USE_LIB -DSTATICLIB -DUS
E_UPNP=0 -I"C:\boost-1.47.0-mgw" -I"C:\db-4.8.30.NC-mgw\build_unix" -I"C:\openss
l-1.0.0d-mgw\include" -I"C:\wxWidgets-2.9.2-mgw\lib\gcc_lib\mswud" -I"C:\wxWidge
ts-2.9.2-mgw\include" -I"C:\miniupnpc-1.6-mgw" -DGUI -o obj/crypter.o crypter.cp
p
In file included from headers.h:94:0,
                 from crypter.cpp:9:
util.h:582:16: error: conflicting declaration 'typedef void* pthread_t'
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:571:24: erro
r: 'pthread_t' has a previous declaration as 'typedef struct ptw32_handle_t pthr
ead_t'
util.h: In function 'pthread_t CreateThread(void (*)(void*), void*, bool)':
util.h:598:27: error: no matching function for call to 'ptw32_handle_t::ptw32_ha
ndle_t(int)'
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note:
 candidates are: ptw32_handle_t::ptw32_handle_t()
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note:
                 ptw32_handle_t::ptw32_handle_t(const ptw32_handle_t&)
util.h:603:28: error: no matching function for call to 'ptw32_handle_t::ptw32_ha
ndle_t(int)'
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note:
 candidates are: ptw32_handle_t::ptw32_handle_t()
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note:
                 ptw32_handle_t::ptw32_handle_t(const ptw32_handle_t&)
util.h:605:12: error: conversion from 'void*' to non-scalar type 'pthread_t' req
uested
util.h: In function 'bool AffinityBugWorkaround(void (*)(void*))':
util.h:673:36: error: no match for 'operator!' in '!CreateThread(pfn, 0u, 0)'
util.h:673:36: note: candidate is: operator!(bool) <built-in>
mingw32-make: *** [obj/crypter.o] Error 1

C:\bitcoin-bitcoin-f8937b2\src>

Also, here's my MinGW version info, provided by this batch file (http://forums.codeblocks.org/index.php/topic,9054.msg65050.html), in case it becomes relevant.

Code:
MINGWBASEDIR=C:\MinGW
gcc version 4.5.2 (GCC)
gcc version 4.5.2 (GCC)
GNU gdb (GDB) 7.2
GNU ld (GNU Binutils) 2.21.1
GNU windres (GNU Binutils) 2.21.1
GNU dlltool (GNU Binutils) 2.21.1
GNU Make 3.82
#define __MINGW32_VERSION           3.18
#define __W32API_VERSION 3.17

This is not the first time I've tried compiling something like this, but certainly it is the first I've tried to do so in Windows, and the first time I've tried with a project this big, so I know I was asking for trouble.  ;D From the output, the first I thought about (Given the declaration conflict) was that the headers were being added in the wrong order, but I tinkered a bit with that, no dice. Any more ideas?  :-[ Thanks in advance!


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: piotr_n on October 22, 2011, 06:33:07 PM
I'm having exactly the same problem.

Any ideas how to deal with it?


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: JoelKatz on October 22, 2011, 06:43:33 PM
I don't believe you can compile the Windows GUI version under MinGW. You should be able to compile the daemon version -- just don't tell it that it's compiling under Windows -- use the standard UNIX makefile. Some tweaks might be needed.


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: piotr_n on October 22, 2011, 07:08:26 PM
I can compile 0.3.x in my MinGW - both GUI and the daemon. No problems with that.

And for 0.4.0 this error happens no matter if I try to compile GUI or the daemon - it actually crashes while compiling the first source file.


Code:
$ make bitcoind.exe
g++ -c -mthreads -O2 -w -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL
 -DBOOST_THREAD_USE_LIB -I"K:\boost-1.47.0-mgw" -I"K:\db-4.8.30.NC-mgw\build_unix" -I"K:\openssl-1.0.0d-mgw\include" -I"
K:\wxWidgets-2.9.2-mgw\lib\gcc_lib\mswud" -I"K:\wxWidgets-2.9.2-mgw\include" -o obj/nogui/crypter.o crypter.cpp
In file included from headers.h:94:0,
                 from crypter.cpp:9:
util.h:582:16: error: conflicting declaration 'typedef void* pthread_t'
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:571:24: error: 'pthread_t' has a previous declaratio
n as 'typedef struct ptw32_handle_t pthread_t'
util.h: In function 'pthread_t CreateThread(void (*)(void*), void*, bool)':
util.h:598:27: error: no matching function for call to 'ptw32_handle_t::ptw32_handle_t(int)'
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note: candidates are: ptw32_handle_t::ptw32_h
andle_t()
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note:                 ptw32_handle_t::ptw32_h
andle_t(const ptw32_handle_t&)
util.h:603:28: error: no matching function for call to 'ptw32_handle_t::ptw32_handle_t(int)'
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note: candidates are: ptw32_handle_t::ptw32_h
andle_t()
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/pthread.h:569:3: note:                 ptw32_handle_t::ptw32_h
andle_t(const ptw32_handle_t&)
util.h:605:12: error: conversion from 'void*' to non-scalar type 'pthread_t' requested
util.h: In function 'bool AffinityBugWorkaround(void (*)(void*))':
util.h:673:36: error: no match for 'operator!' in '!CreateThread(pfn, 0u, 0)'
util.h:673:36: note: candidate is: operator!(bool) <built-in>
make: *** [obj/nogui/crypter.o] Error 1


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: JoelKatz on October 22, 2011, 08:37:46 PM
Well, you can use quick hacks to solve these specific issues. Remove the definition of 'pthread_t' from the header file and remove the test of the return value of 'CreateThread'.


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: piotr_n on October 22, 2011, 08:59:04 PM
Thanks!
Your advise made me thinking... and I figured how to fix it.  :)

The problem is in the db.h from the berkeley database - it includes ptherad.h, which screws things up.

All you have to do is just append -D__NO_SYSTEM_INCLUDES at the DEFS= in makefile.mingw

Now it compiles


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: ChaosFox on October 24, 2011, 12:13:13 AM
Thanks!
Your advise made me thinking... and I figured how to fix it.  :)

The problem is in the db.h from the berkeley database - it includes ptherad.h, which screws things up.

All you have to do is just append -D__NO_SYSTEM_INCLUDES at the DEFS= in makefile.mingw

Now it compiles

Thanks a lot! I'll try this as soon as I get to my home PC.  ;D


Title: Re: Problems compiling Bitcoin 0.4.0 in Windows 7 x64 (MinGW Environment)
Post by: shakezula on May 17, 2013, 04:35:58 PM
Thanks!
Your advise made me thinking... and I figured how to fix it.  :)

The problem is in the db.h from the berkeley database - it includes ptherad.h, which screws things up.

All you have to do is just append -D__NO_SYSTEM_INCLUDES at the DEFS= in makefile.mingw

Now it compiles

Thanks a lot! I'll try this as soon as I get to my home PC.  ;D

I know this is waaay old news, but this fixed it for me too, thanks!