I am still learning and this is just a guide based on what I have found as a Windows user trying to compile for Windows. This guide is intended for people who aren't as familiar with Linux so I go into more details about a few things.
First off don’t even bother with the windows build instructions. Last I checked it's not kept up to date and hasn’t worked properly in quite some time. The way windows binary’s are compiled is using gitian builder in Ubuntu. It creates a virtual environment that compiles the sources within it so that anybody can build software and get the same file in the end. So the first thing you will need is Ubuntu 64-bit and you will need version 10 as I know 11 has issues. Now I have noticed 12 is out, but I haven’t tested it.
Anyways the version I used was the long term support ubuntu-10.04.4-desktop-amd64
http://releases.ubuntu.com/lucid/. Next you will need some kind of virtual environment such as VirtualBox or VMware. I used VMware workstation, but whatever you choose ensure you enable hardware virtualization. Which in VMware it is located under the VM settings in the processors setting and called “Virtualize Intel VT –x/EPT or AMD-V/RVI”. This can make a very significant difference in the compiling speed. Also you want to only have one core per processor and max out the processors as when I was testing I noticed gitian performed better that way.
Note: If using VMware the arrow keys are messed up in vi so to fix that I had to edit vimrc.tiny
sudo vi /etc/vim/vimrc.tiny
Go down to the line that says “set compatible” then just double press d to delete the line then press i to insert some text and type “set nocompatible” then press esc and do a :wq to save the file. You cant use the arrow keys so if you mess up just press esc then type :q! to force quit and try again.Also if you are using VMware I know you can drag and drop files between host and VM, but I have noticed sometimes the virtual tries moving the file before its finished copying to the virtual. I just wait till it’s done copying and clicking the retry on the error popup. Also I have noticed a file has occasionally become corrupt from copying so I normally open the zips and such to see if it gives errors.So after you have installed Ubuntu on your virtual you will need to install some applications. Open a terminal window found under the menu applications/accessories/terminal and run
sudo apt-get install python-vm-builder qemu-kvm apt-cacher ruby
During install, a package configuration window will popup. Just tab to the ok and on the next screen select no configuration. Once they are installed run
sudo service apt-cacher start
It will tell you how it’s not enabled in /etc/default/apt-cacher so run
sudo vi /etc/default/apt-cacher
and go down the the autostart line and change the 0 to a 1. This is so now it autostarts when you reboot Ubuntu.
Now you need gitian which can be found
https://github.com/devrandom/gitian-builder I just download the zip of it as I prefer keeping a backup if needed, but you can install git and use that if you want.
Extract gitian onto your desktop and have it so that the main sub-folders are in a gitian folder on your desktop like /Desktop/gitian/bin/gbuild
Next download the bitcoin source you want from
https://github.com/bitcoin/bitcoin/tags also I know one of the developers has some other tags at
https://gitorious.org/bitcoin/bitcoind-stable/trees/0.5.xThen extract it to the desktop and name the folder bitcoin so the folder structure is such /Desktop/bitcoin/readme.md
Note: Only the current branch which is 6 at this time is actively developed, though 4 and 5 do have bug fixes.You will also need a clean copy of bitcoin source zipped so right click the bitcoin folder on your desktop and click compress. Name it bitcoin-6.2 and choose zip from the dropdown.
Note: If you are planning on using some modified bitcoin code you should first finish your modifications to the source before you make that zip as that zip is what will be used later during the actual compiling of bitcoin in the virtual.Now with gitian being a virtual in a virtual it’s going to suffer some performance and because of that I have noticed you need to modify some of the gitian files. So open gitian/bin/gbuild and when asked just select display. Modify line 60 from "(1..10).each do" to
Then in the gitian/libexec folder change the copy-from-target line 50 from " -oConnectTimeout=5" to
Then do the same thing in the copy-to-target, but for on-target I just used 30
Also for start-target I changed the " -smp ${NPROCS:-2}" to "-smp 2"
I have 4 processors on the VM noticed it was only using 1/4 of my processors so I wanted to force it to use more for better performance. Though I did find out using 3/4 would cause issues so just use half of your total.
Note: You can tab most things to auto fill the name such as typing De then tab will fill Desktop/Now it's time to build the gitian virtual. In a new terminal window go to your gitian folder by cd Desktop/gitian/ and run
sudo bin/make-base-vm -a i386
I had to use sudo because half the time without it would cause problems. Now this will probably take a few minutes and look like it’s not doing anything, but just wait for it. While waiting you can work on the other parts.
If you open your bitcoin folder and go to /contrib/gitian-descriptors/gitian-win32.yml and in the “files:” section, which is line 17 in 6.2, you will see it list a few zip files which you will need. To get them you will need to compile them and to do that you will use those other .yml files.
The first one is qt-win32-4.7.4-gitian.zip so opening qt-win32.yml and in files section you will see this needs qt-everywhere-opensource-src-4.7.4.tar.gz which can be found at
http://ftp://ftp.qt.nokia.com/qt/source/Just make sure you are downloading that correct file, I just used ctrl+f to search for it.
Next requirement from gitian-win32.yml is boost-win32-1.47.0-gitian.zip. So opening boost-win32.yml we see it needs boost_1_47_0.tar.bz2 found at
http://sourceforge.net/projects/boost/files/boost/1.47.0/Then the final file in gitian-win32.yml is bitcoin-deps-0.0.4.zip so in deps-win32.yml we see it needs quite a few.
openssl-1.0.1b.tar.gz at
http://www.openssl.org/source/db-4.8.30.NC.tar.gz at
http://www.oracle.com/technetwork/products/berkeleydb/downloads/index-082944.html (called Berkeley DB 4.8.30NC.tar.gz)
miniupnpc-1.6.tar.gz at
http://miniupnp.free.fr/files/zlib-1.2.6.tar.gz at
http://sourceforge.net/projects/libpng/files/zlib/1.2.6/libpng-1.5.9.tar.gz at
http://sourceforge.net/projects/libpng/files/libpng15/older-releases/1.5.9/qrencode-3.2.0.tar.bz2 (notice it’s the bz2 version) at
http://fukuchi.org/works/qrencode/index.html.enOk so now we should have all the sources needed they all need to be copied/moved to a new folder called inputs in your gitian folder so its Desktop/gitian/inputs
Now your virtual should be done building and you can start compiling the dependencies. I’ll go down the list starting with qt we run
sudo bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-win32.yml
This can take quite some time.
Note: If after you enter your sudo password and it starts the VM, but then asks about some @localhost password you need to reboot and delete the /gitian/target-lucid-i386.qcow2 and /gitian/var/target.pid which you may have to do by “sudo rm target.pid” and then try again.
If you get an error about on-target or banner or some kind of timeout then try increasing the gbuild loop number number and/or the on-target timout. Also make sure you aren’t using too many processors as mine would never connect when using more than half. If you have some warning about kvm not loaded that means you don't have hardware acceleration enabled. It should still work, but will be extremely slow, many hours when I tested it, and you may have to increase the gbuild loop and connection timeouts.
Once is is done it will put the files in /gitian/build/out/ and you must copy them to your inputs folder before you build the next one as outputs is erased on each gbuild. Also after each build I normally deleted the target vm and the target.pid because I found that tend to help with any issues I would sometimes get.
So next one is boost which we run
sudo bin/gbuild ../bitcoin/contrib/gitian-descriptors/boost-win32.yml
And the final dependency is bitcoin-deps which is
sudo bin/gbuild ../bitcoin/contrib/gitian-descriptors/deps-win32.yml
Now we should have all dependencies for bitcoin, but there are a few things we need to do before compiling bitcoin. By default gitian-win32.yml will always try downloading the most recent source to use for compiling. Well I don’t want that because I want to use my source so we need to modify a few things.
In gitian-win32.yml change the “remotes:” section lines 14-16 to "remotes: []"
Then under “files:” add
Then above the now line 45 “cd bitcoin” add
unzip bitcoin-6.2.zip
cp -r bitcoin $OUTDIR/src
cp -r bitcoin nsis
Next delete the now line 49 and 50 that start with mkdir and git. Then scroll down and replace now line 67 and 68 which are mkdir and git, with
Now take that clean bitcoin-6.2.zip from the desktop and put it in the inputs folder. Then start the compiling by running
sudo bin/gbuild ../bitcoin/contrib/gitian-descriptors/gitian-win32.yml
After a while it should put the windows installer in the /gitian/build/out
I have tried this a couple times and the installer and bitcoin works, but for some reason my hashes aren't matching the developers. It could be from some of the changes I made, but I don't think that should matter because I am using the same source.
All of this should work with any source you use so you can use your own modified code, but if using older major releases I know 4 and 5 has different dependencies so you will need to find and compile them.
So I started all of this because I wanted to use a slightly modified client with the 5 branch. I need version 5 as I still test Armory and it doesn't support the new compressed wallets. So here are the few differences if you want to use version 5.
If you followed the above instructions you should already have all the dependencies needed for 5.5 so the only thing you will need to do is first take your 5.5 source, modified or not, and make a zip of it.
The zip file structure should be so that when you open it there is a folder called "bitcoin" and within it starts all the files/folder like the contrib folder. Next name it bitcoin-5.5.zip and stick it in your inputs folder.
Then modify the /Desktop/bitcoin/contrib/gitian-descriptors/gitian-win32.yml which should have your 5.5 source in that bitcoin folder. We do the same thing with remotes making it "remotes: []". Then add the
to the files section. Then the only other thing we have to do is add
to above now line 64 which has the " cd bitcoin". Thats it then just compile it like you would above.
If there are any suggestions or things I messed up please let me know and I'll update the guide.