windows build instructions don't work #1401

Closed
rebroad opened this Issue May 31, 2012 · 56 comments

8 participants

@rebroad

bitcoin-qt.pro as it is doesn't let Qt Creator create a working Makefile.

Currently the creation of build.h has to be done manually, and the "genbuild.depends = FORCE" line needs the FORCE removing.

@Diapolo

I observed this, too ... I comment the build-stuff out to get this working, but a real fix would be a great thing!

@sipa
Bitcoin member

Strange, that part of the file is inside a !windows block. I wonder why it gets evaluated.

@Diapolo

@sipa Yeah that's strange, but it won't compile with that part enabled ...

@rebroad

@Diapolo Have you got it compiling on Windows recently? I'm getting:

e:/nokiaqtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x13f): undefined reference to `shutdown@8'

e:/nokiaqtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x3af): undefined reference to `shutdown@8'

a problem in openssl?

@Diapolo

Yes I'm compiling fine on Windows but had to change a few things in the pro file.

  1. I use Boost 1.49 and compiled the libs.
  2. I exclude support for QR-Codes as I could't figure out how to compile that.
  3. I exclude the "regenerate src/build.h" part
  4. I had to re-order the used libs and add -loleaut32

Edit: You extracted the pre-compiled needed lib package into the MinGW dir? See: https://github.com/bitcoin/bitcoin/blob/master/doc/readme-qt.rst

And this dependency package badly needs an update ... but no one seems to be able to do this or remember, who created it.

@mhredmond21

put ws2_32 and shlwapi libraries after ssl and crypto

@Diapolo

@mhredmond21 It would be good to know what is the best / safest ordering to add libs in the .pro file. I got it working for myself and currently have:

windows:LIBS += -lshlwapi
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX
windows:LIBS += -lws2_32 -lole32 -loleaut32 -luuid -lgdi32
LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX

I needed to add -loleaut32, dunno what needed this, could be boost 1.49. And I needed to re-order another one. This compiles just fine, but I'm not that sure about the ordering ...

@mhredmond21

I finally got my bitcoin-qt working. Thanks Diapolo for your hints.

instructions to build bitcoin-qt on windows --

Get the QT Windows SDK

get master branch from github (I used EGit that comes with eclipse)

http://download.visucore.com/bitcoin/qtgui_deps_1.zip << download this, but the boost package is too old
https://bitcointalk.org/index.php?topic=77235.msg863514 << follow these instructions (from diapolo) to build boost

edit bitcoin-qt.pro in the root of the bitcoin branch

add these lines where it says in comments (adjust to your hard drive layout )

BOOST_INCLUDE_PATH = "E:\boost-1.47.0-mgw"
BOOST_LIB_PATH = "E:\boost-1.47.0-mgw\build"
BDB_INCLUDE_PATH = "E:\deps\include"
BDB_LIB_PATH = "E:\deps\lib"
OPENSSL_INCLUDE_PATH = "E:\deps\include\openssl"
OPENSSL_LIB_PATH = "E:\deps\lib"
MINIUPNPC_INCLUDE_PATH = "E:\miniupnpc-1.6-mgw"
MINIUPNPC_LIB_PATH = "E:\miniupnpc-1.6-mgw"
BOOST_LIB_SUFFIX = "-mgw44-mt-s-1_47"

also edit the section where the libraries were specified to look like diapolo's post above. Also comment out the genbuild.sh section as he says.

Click the "projects" button

Turn off shadow build. Add the additional arguments USE_UPNP=- to qmake build steps and -f Makefile.Release to the make build steps.

Click "build" tab, and run QMake. Then build and run.

@Diapolo

@mhredmond21 Well I don't need to add local paths like you do. Seems like some paths are missing in the %PATH% environment variable or I have the libs and headers in the right place. But I'm glad you got it working.

@mhredmond21

I didn't even think to try it like that. I was mainly focused on trying to replicate what worked for bitcoind build (makefile.mingw). I appreciate all your tips.

@Diapolo

Everyone who is able to compile on Windows is of great help :). Are you planning to contribute via pulls / patches?

@mhredmond21

I plan to write patches but I am unsure if anybody will pull them. ;)

@EnasQ

also -lwsock32 is missing

@Diapolo

No it's not -lws2_32 or what compilation errors do you get?

@EnasQ

also now I when I put USE_UPNP=-

qmake.exe C:\bitcoin-bitcoin-v0.6.1-621-g12e5881\bitcoin-bitcoin-12e5881\bitcoin-qt.pro -r -spec win32-g++ USE_UPNP=-

it does not work with me..
what is the exact format?

@Diapolo

According to MS GetAcceptExSockaddrs() requires Mswsock, see http://msdn.microsoft.com/en-us/library/windows/desktop/ms738516%28v=vs.85%29.aspx.

Edit: Use "USE_UPNP=-" to disable UPNP support.

@EnasQ

I got this error when I tried to run my bitcoin-qt.exe .. mingw10.dll is missing.. !! what to do? :((((

@Diapolo

Seems your PATH environment variable does not include the path to MinGW. If you have MinGW installed in D:\MinGW, you need to include D:\MinGW\bin in PATH. That is because on Windows we get no statically linked bitcoin-qt binary and so it needs mingw10.dll and some other libs.

@EnasQ

I added c:\MinGW\bin to the path and it does not work

@Diapolo

Can you confirm that mingw10.dll is in C:\MinGW\bin? Btw. I only have mingwm10.dll (m added) in my bin folder, but perhaps you had a typo or that is because of my MinGW version. Is the error message the same (missing mingw10.dll)?

@EnasQ

I had it in minwg\bin folder both that for qt creator (4.7) and the stand-alone one which I installed I dunno which version is it

@Diapolo

Without more detailed information I'm unable to help any further beyond this, sorry.

@EnasQ

I did this:
1. copied the bitcoin-qt.exe to the bin directory of mingw which is inside the Qtsdk (I used qt creator mingw to compile )
2. executed the bitcoin it gave me the following error: the procedure point _ZNK7QLocale17nativeCountryNameEv could not be located in the dynamic link library QtCored4.dll.

@EnasQ

yes its typo mingwm10.dll :) .. but what to do now?

@EnasQ

C:\QtSDK\Desktop\Qt\4.8.0\mingw\bin I copied bitcoin there but then no output and no errors!!

@Diapolo

Alright, I guess I know what the problem is.

  1. Uninstall or remove the seperate MinGW installation, you have the Qt SDK installed, right? This has an compatible MinGW 4.4 integrated.

  2. Now you have to add not only MinGW\bin to your PATH variable, but also %QTDIR%\lib and %QTDIR%\bin, where QTDIR is the path to the Qt installation (on my system this is D:\Qt_4.8.2).

The bitcoin-qt.exe depends on several libs that are in these 3 folders!

@EnasQ

mingw version is 4.4

@Diapolo

Come on ... try to read ... that IS what I said above. Current Qt SDK has MinGW 4.4...

@EnasQ

OK I did this :
1. add to the path the following addresses
C:\QtSDK\mingw\lib;C:\QtSDK\QtCreator\bin;C:\QtSDK\QtCreator\lib
2. compiled again for 4.8 qt mingw4.4 as u said
but still the problem gives me error can not fin mingwm10.dll and when I copy the .exe file to C:\QtSDK\Desktop\Qt\4.8.0\mingw\bin
I got silent application; that means no gui appears and no error messages .. nothing :(((

@Diapolo

Ok, this is my last try!

  1. Not C:\QtSDK\mingw\lib but C:\QtSDK\mingw\bin
  2. I'm sure the QTDIR path is wrong ... in QTDIR\bin there is e.g. a assistant.exe and in QTDIR\lib for example a QtDeclarative4.dll. Verify the paths please!
  3. When bitcoin-qt.exe gives no error / warning message it should perhaps create a debug.log in C:\Users\%USERNAME%\AppData\Roaming\Bitcoin
@EnasQ

C:\QtSDK\QtCreator\bin containsthe dll you mentioned, I had those paths added to my PATH variable:
C:\QtSDK\mingw\bin;C:\QtSDK\QtCreator\bin;C:\QtSDK\QtCreator\lib
and gor the same problem : missing mingwm10.dll.
and if I copied the file to C:\QtSDK\Desktop\Qt\4.8.0\mingw\bin
again silent execution . I checked the debug.log file its too old . I deleted the previous debug.log file .. and executed teh .exe no log file created. I really want help please its 10 days am trying to get bitcoin built on windows and now it not working .
I have my master thesis on some adaptation of bitcoin for other type of commidity trading. please help me what to do?

@Diapolo

I AM sure that C:\QtSDK\QtCreator\bin is NOT correct, that is all I can say. Take another look if the mentioned files or paths are there twice and you chose the wrong one.

Please download and use https://qt.nokia.com/downloads/sdk-windows-cpp and perhaps try again with that.

@EnasQ

I fixed the bitcoin was partialy launched (the logo only) then crashed.

I have this in the debug log:

Bitcoin version v0.6.99.0-g12e5881-beta ($Format:%cD)
Startup time: 07/27/12 21:27:25
Default data directory C:\Users\ealkawasmi\AppData\Roaming\Bitcoin
Used data directory C:\Users\ealkawasmi\AppData\Roaming\Bitcoin
Loading block index...
dbenv.open LogDir=C:\Users\ealkawasmi\AppData\Roaming\Bitcoin\database ErrorFile=C:\Users\ealkawasmi\AppData\Roaming\Bitcoin\db.log


EXCEPTION: 22DbRunRecoveryException

DbEnv::open: DB_RUNRECOVERY: Fatal error, run database recovery

C:\bitcoin-bitcoin-12e5881\debug\bitcoin-qt.exe in Runaway exception

I put this in the PATH: C:\QtSDK\mingw\bin;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin

@EnasQ

I found the solution in this link in another issue: #809
I am soooooooooooooooo happy now I can sleep . The real work will start .

@EnasQ

I have this issue today teh debug version of bitcoin works fine and every thing is ok.
BUT: the release version doesn't work and gives this error!!
The procedure entry point Z21qRegisterResourcesDataiPKhS0_S0 could not be locatedin dynamic link library QtCore4.dll.
what to do?

@Diapolo

I still think you are using wrong paths in the PATH variable...

@EnasQ

but the debug version works fine with me .. why the release not?
I re-installed QTSDK only version 4.8.1 to avoid version clashes and with Mingw 4.4 only for desktop development only
I searched my laptop and found many other qtcor4.dll but for other applications like nokia suit and mendely desktop and latex editor. and I had one in C:\QtSDK\QtCreator\bin and C:\QtSDK\QtCreator\lib and C:\QtSDK\Desktop\Qt\4.8.0\mingw\lib
which to put in my PATH variable?

@Diapolo

I have currently not installed the QtSDK, but AFAIK it won't hurt to add all of them ... important is that the executable finds it's needed libs. Btw. did you specify "RELEASE=1" for qmake?

@laanwj
Bitcoin member

There's another thing that currently prevent the windows build in a 'bare' Qt SDK (current version - 1.2.1) from working: packaged mingw binutils don't support -Wl,--dynamicbase -Wl,--nxcompat

I really wish they would release a new Qt Sdk with mingw 4.6.x, that'd fix a lot of these issues and make it possible again for me to cross-build the dependencies.

@Diapolo

You mean the Qt SDK integrated MinGW 4.4 does not support DEP / ASLR switches? I'm rather sure I was able to use them on Windows with the default SDK.

Btw. current Qt 4.8.3 seems to cause some problems on Windows too:
https://bugreports.qt-project.org/browse/QTBUG-27244

@laanwj
Bitcoin member

When I last tried, it was failing on some security-related switches. I'm not sure which ones, anymore.

@laanwj
Bitcoin member

Anyone still planning to update the windows build instructions? @Diapolo?

@old-c-coder

Yes! I plan to. Among other things, first, though, is getting the daemon bitcoind.exe to work correctly on windows! Then bitcoin-qt.exe. Then a windows .dsw, .sln or other VC++ Express freebie IDE build. I am a fan of VC++ 6.0 (how's that for old!) and VC++ Express 2005, which seems to have a links to the past and the future! Ron

@rebroad

No progress on this at all...?

@old-c-coder

Hello rebroad,

Au contraire, see
https://bitcointalk.org/index.php?topic=149479.0;all
especially, messages numbers 41, 85, 160, 176 (gcc) and 222, 228, 230 (MSVC++)

Ron

@Diapolo

@old-c-coder I'm still hoping you supply some patches for us, sad you didn't yet participate here.

@bc4-old-c-coder

Hello Diapolo, rebroad...

See message # 550 at
https://bitcointalk.org/index.php?topic=149479.msg6277122#msg6277122
and # 43 at
https://bitcointalk.org/index.php?topic=349094.msg6284139#msg6284139

See https://github.com/bc4-old-c-coder/bitcoin/tree/0.8.6
There are sources there that compile, link and run bitcoind 0.8.6, with OpenSSL 1.0.1g BTW!
Just the videos are missing on how to make the four libraries for bitcoin and any other *coin too, and these will be posted shortly.

Ron

@laanwj
Bitcoin member

Is anyone going to update the build instructions in doc/build-msw.md?

If not, I am going to remove them. They have been broken for a long time, and it's better to have no instruction than one that is so broken/outdated.

@bc4-old-c-coder

Hello Wladimir,

I can give doc/build-msw.md a "freshening". But really nitrogenetics message # 1 in
https://bitcointalk.org/index.php?topic=149479.msg1587734#msg1587734
aka Building headless Bitcoin and Bitcoin-qt on Windows is the "prevailing wisdom". It is also an organic process, since bitcoin's linux build is changing too. On the other side of the coin, the build on Windows using MSVC++ is much cleaner! I can allude to that too in the build-msw.md, if you would like?

Ron

@laanwj
Bitcoin member

Personally I prefer self-contained build instructions in a document to a forum topic.

Anything in the repository is 'organic' as well, although it has to be kept up to date with master.

If you want to add MSVC build instructions as well that is great. It's less-well tested though. Does the resulting executable pass the unit tests?

@bc4-old-c-coder

Hello Wladimir,

I will try the unit tests on MSVC++.

Ron

@bc4-old-c-coder

Hello Wladimir,

After some trouble with the usual zero length vector<> references, I get:

Running 93 test cases...
src/test/netbase_tests.cpp(17): error in "netbase_networks": check CNetAddr("2001::8888").GetNetwork() == NET_IPV6 failed
src/test/netbase_tests.cpp(18): error in "netbase_networks": check CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_TOR failed

src/test/netbase_tests.cpp(24): error in "netbase_properties": check CNetAddr("::FFFF:192.168.1.1").IsIPv4() failed
src/test/netbase_tests.cpp(29): error in "netbase_properties": check CNetAddr("2001:0DB8::").IsRFC3849() failed
src/test/netbase_tests.cpp(31): error in "netbase_properties": check CNetAddr("2002::1").IsRFC3964() failed
src/test/netbase_tests.cpp(32): error in "netbase_properties": check CNetAddr("FC00::").IsRFC4193() failed
src/test/netbase_tests.cpp(33): error in "netbase_properties": check CNetAddr("2001::2").IsRFC4380() failed
src/test/netbase_tests.cpp(34): error in "netbase_properties": check CNetAddr("2001:10::").IsRFC4843() failed
src/test/netbase_tests.cpp(35): error in "netbase_properties": check CNetAddr("FE80::").IsRFC4862() failed
src/test/netbase_tests.cpp(36): error in "netbase_properties": check CNetAddr("64:FF9B::").IsRFC6052() failed
src/test/netbase_tests.cpp(37): error in "netbase_properties": check CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").IsTor() failed
src/test/netbase_tests.cpp(39): error in "netbase_properties": check CNetAddr("::1").IsLocal() failed
src/test/netbase_tests.cpp(41): error in "netbase_properties": check CNetAddr("2001::1").IsRoutable() failed

src/test/netbase_tests.cpp(84): error in "netbase_lookupnumeric": check TestParse("::50:127.0.0.1", "127.0.0.1:80") failed
src/test/netbase_tests.cpp(84): error in "netbase_lookupnumeric": check TestParse("::ffff:127.0.0.1", "127.0.0.1:65535") failed
src/test/netbase_tests.cpp(85): error in "netbase_lookupnumeric": check TestParse("::", "[::]:65535") failed
src/test/netbase_tests.cpp(86): error in "netbase_lookupnumeric": check TestParse("[::]:8333", "[::]:8333") failed

src/test/netbase_tests.cpp(96): error in "onioncat_test": check addr1 == addr2 failed

*** 17 failures detected in test suite "Bitcoin Test Suite"
in about 11 seconds.

This is reasonable on my ipv4 static ip lan with no port forwarding and no upnp.

Ron

@laanwj
Bitcoin member

Yes I've seen the IPv6 tests fail before on Windows, that's not a big deal. UPnP and port forwarding should have no effect on the tests.

@laanwj
Bitcoin member

I removed the hopelessly outdated doc/build-msw.md.

Anyone building bitcoind/-qt on windows is welcome to contribute a new one.

@bc4-old-c-coder

Hello Wladimir,

I only see it in a mono-spaced font (in my IDE) so I don't know how to "markdown" it nicely,
but how about something like this?


Copyright (c) 2009-2013 Bitcoin Developers

Distributed under the MIT/X11 software license, see the accompanying
file COPYING or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. This product includes
cryptographic software written by Eric Young (eay@cryptsoft.com), and UPnP software written by Thomas Bernard.

See readme-qt.rst for instructions on building Bitcoin-Qt, the
graphical user interface.

WINDOWS BUILD NOTES

Compilers Supported

TODO: What works?

See https://bitcointalk.org/index.php?topic=149479.msg1587734#msg1587734
which is message #1 on the bitcointalk.org group
Building headless Bitcoin and Bitcoin-qt on Windows

There, the complete exposition of building Bitcoind and Bitcoin-Qt on Windows is given.
It is a dynamic process since the four libraries, the gcc compiler and the Bitcoin sources
are all "evolving".

gcc in a MinGW shell or a command box (dos window) on Windows.
Back in early 2013, the gcc version "du jour" was 4.6.2, though now it is 4.8.3, 4.9.1?

Note: releases are cross-compiled using mingw running on Linux.

As in the forum above, one can build in Windows, running a MinGW shell as needed.

One can also compile and run a MSVC++ version of Bitcoind.exe in MSVS any version,
personally my favorite.

Dependencies

Libraries you need to download separately and build:

                    default path                  download

OpenSSL \openssl-1.0.1h http://www.openssl.org/source/

Berkeley DB \db-4.8.30.NC http://www.oracle.com/technology/software/products/berkeley-db/index.html

Boost see versions at http://www.boost.org/users/history/
\boost-1.53.0-mgw, http://sourceforge.net/projects/boost/files/boost/1.53.0/
or
\boost-1.55.0-mgw, http://sourceforge.net/projects/boost/files/boost/1.55.0/

levelDB ...\src\leveldb https://code.google.com/p/leveldb/downloads/list

(optional)miniupnpc \miniupnpc-1.9 http://miniupnp.tuxfamily.org/files/

Their licenses:

OpenSSL        Old BSD license with the problematic advertising requirement
Berkeley DB    New BSD license with additional requirement that linked software must be free open source
Boost          MIT-like license
miniupnpc      New (3-clause) BSD license

Versions used in this release:

OpenSSL      1.0.1h
Berkeley DB  4.8.30.NC
Boost        1.55.0
levelDB      1.15
miniupnpc    1.9    this is optional

The exposition below is better done in the forum mentioned above.

OpenSSL

MSYS shell:

un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)
change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'

cd /c/openssl-1.0.1h-mgw
./config
make

Berkeley DB

MSYS shell:

cd /c/db-4.8.30.NC-mgw/build_unix
sh ../dist/configure --enable-mingw --enable-cxx
make

Boost

DOS prompt:

downloaded boost jam 3.1.18
cd \boost-1.55.0-mgw
bjam toolset=gcc --build-type=complete stage

MiniUPnPc

UPnP support is optional, make with USE_UPNP= to disable it.

MSYS shell:

cd /c/miniupnpc-1.9-mgw
make -f Makefile.mingw
mkdir miniupnpc
cp *.h miniupnpc/

Bitcoin

DOS prompt:

cd \bitcoin\src
mingw32-make -f makefile.mingw
strip bitcoind.exe
@laanwj laanwj added a commit to laanwj/bitcoin that referenced this issue Nov 4, 2015
@laanwj laanwj build: Improve build instructions
- Add package instructions for Ubuntu 15.10
- Clarify BerkeleyDB/wallet situation for unix
- Add basic build instructions for Windows (closes #1401)
35bb381
@laanwj laanwj closed this in #6933 Nov 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment