The latest btcd release build is from 2015. There is a nice description how to build it for Linux/Mac, but for Windows it’s suggested to download the latest binaries, which are 626 commits behind master as of February 2018. Fortunately, with Golang we can easily build binaries for Windows, and we can follow the steps of the Linux build process. The only issue I faced was a problem in the Glide dependency manager and that’s how this little post was born.

note
We assume that Go is installed and GOPATH and GOROOT are configured.

We can attempt to build and install it for Windows with the steps below:

1
2
3
4
5
6
7
c:\> go get -u github.com/Masterminds/glide
c:\> mkdir btcsuite
c:\> cd btcsuite
c:\btcsuite> git clone https://github.com/btcsuite/btcd
c:\btcsuite> cd btcd
c:\btcsuite\btcd> glide install
c:\btcsuite\btcd> go install . ./cmd/...

The first command downloads and installs Glide. The following commands create a folder where the btcd repo will be cloned. After cloning the repo we must run glide install to get all btcd dependencies.

The issue happens on the line glide install and the error is something like: Unable to export dependencies to vendor directory

This seems to be a problem with the Glide tool and to fix it, we must change one line of code in $GOPATH/src/github.com/Masterminds/glide/path/winbug.go and rebuild the Glide tool.

In the function CustomRename, we have to replace

1
cmd := exec.Command("cmd.exe", "/c", "move", o, n)

with

1
cmd := exec.Command("cmd.exe", "/c", "xcopy /s/y", o, n+"\\")

Then change to the glide directory and rebuild it.

1
2
3
c:\> cd %GOPATH%\src\github.com\Masterminds\glide
c:\goprojects\src\github.com\Masterminds\glide> go build
c:\goprojects\src\github.com\Masterminds\glide> go install

Now we’re ready to run glide install again in the btcd folder and everything should be fine.

tip
If you want to store the blockchain on a different drive (i.e. not C:), read below.

If we want to change the default folder where btcd will download and store the blockchain, we can create a symbolic link, similar to ln -s in Linux. I wanted to change it, because I have a small 128GB SSD drive for booting Windows (C:) and 1TB spinning drive (D:) where I would like to store the data.

By default btcd stores the blockchain in c:\Users\your-user\AppData\Local\Btcd\data. If we want to move that directory to D: without disturbing the btcd expectations, we can create a symbolic link with the following commands:

First create a folder on drive D: where we’ll store the blockchain, for example:

1
d:\> mkdir btcd-data

Next, we must rename (move) the current data folder created by btcd:

1
c:\Users\your-user\AppData\Local\Btcd> move data data-original

And create the symbolic link:

1
c:\Users\your-user\AppData\Local\Btcd> mklink /d "data" "d:\btcd-data"

Now btcd will have its data directory where it expects it to be, but the blockchain data will actually be stored on drive D: in the d:\btcd-data folder.