How to build the Golang Bitcoin Node for Windows 10 (btcd)

in #bitcoin7 years ago

chain-optimized.jpg

How to build Btcd for Windows 10

 
The latest btcd release build is from 2015. There's 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.

We assume that Golang is installed and GOPATH and GOROOT are configured.

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

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 github.com/Masterminds/glide/path/winbug.go and rebuild Glide.

In the function CustomRename, we have to replace
cmd := exec.Command("cmd.exe", "/c", "move", o, n)
with
cmd := exec.Command("cmd.exe", "/c", "xcopy /s/y", o, n+"\\")

Then change to the glide directory and rebuild it.

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.

Note: If we want to store the blockchain on a different drive (i.e. not C:)

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:

d:\> mkdir btcd-data

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

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

 
And create the symbolic link:

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

 
Now, from btcd perspective it 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.

Sort:  

Congratulations @middlehut! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 90641.97
ETH 3108.44
USDT 1.00
SBD 2.99