With the anniversary update for Windows 10 comes the Linux subsystem on Windows and Ubuntu bash in Windows. For many, this would seem like a minor improvement at best, but the ramifications are much larger! Anyone that has been following Steem or even BitShares for long knows of the woes building and running a Graphene based blockchain on Windows. Those days are coming to an end!
Today I want to walk through building steemd on Windows 10. The instructions are nearly identical as building on Ubuntu, but I will go over them nonetheless. This is a technical guide, but I tried to make it easy enough that an aspiring programmer can follow it and begin playing around with Steem.
Linux Subsystem
First of all, you need to enable the Linux subsystem and install bash. There is a great guide here with pretty pictures, but I will go over the basics in this post as well for the sake of completeness.
Go into Settings > Updates and Security
and select Developer Mode
. As a word of warning, this will allow you to install applications that Windows would normally prevent you from installing. It should go without saying that you should be cautious about what software you install on your computer, but I'm going to say it anyways. Be careful about what you install on your computer! Restart your computer.
Now, go into Control Panel > Programs > Turn Windows features on or off
and select Windows Subsystem for Linux (Beta)
. Yes, this is a beta feature included in a major release, but in my experience is stable enough for use, especially with side projects like Steem! There is one limitation of this being Beta that I will get into later. But for now, everything works as you will expect it to. Restart your computer again.
Bash
When your computer is back up, open command prompt or power-shell, whichever you prefer. Finally, type bash
and watch the magic happen! Your computer will download and install bash. It will prompt you for a username and password. You will only be prompted for your password when attempting to run a command as root using sudo.
Now we are running bash! In the future you can open a terminal and type bash again to launch a bash shell. Alternatively, there is a "Bash on Ubuntu on Windows" app that does the same thing.
Steem
At this point building Steem is identical to building it on Ubuntu. The instructions are largely taken from the Ubuntu build instructions for BitShares here
As always, update apt-get before installing packages.
sudo apt-get update
sudo apt-get install git gcc g++ cmake make libbz2-dev libssl-dev openssl libreadline-dev autoconf libtool doxygen autotools-dev build-essential libicu-dev python-dev bzip2
That is all of the packages we need. The next big dependency is Boost. apt-get does not have a new enough version of Boost, so we need to build from source.
Choose some directory to install Boost to. I chose /mnt/c/git/steem_dep/boost_1_60_0
Save is as BOOST_ROOT=/mnt/c/git/steem_dep/boost_1_60_0
. You can export it if you wish or add it to your bash profile.
In a working folder, not your destination...
wget -c 'http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.bz2/download' -O boost_1_60_0.tar.bz2
tar xjf boost_1_60_0.tar.bz2
cd boost_1_60_0
./bootstrap.sh "--prefix=$BOOST_ROOT"
./b2 install
Building and installing Boost can take a while, so grab a cup of coffee and browse Steemit for a while!
In your git root directory (I like to have all my repos in the same location) clone Steem.
git clone https://github.com/steemit/steem.git
cd steem
git submodule update --init --recursive
By default you will check out the master branch. Unless you are wanting to test new features, this is the branch you want.
Now we build Steem!
cmake -D BOOST_ROOT="$BOOST_ROOT" -D LOW_MEMORY_NODE=ON -D CMAKE_BUILD_TYPE=Release .
make
./programs/steemd/steemd
Tada!
You have now not only built Steem on Windows using a GNU toolchain (No Visual Studio whatsoever) but the steemd executable is a Linux binary and is running on your Windows machine!
There is a lot of information out there on how to set up your node, so I will leave that as an exercise to the reader.
Disclaimer:
Remember when I said the Linux subsystem is in beta? Well here is where is shows. steemd makes good use of the SO_REUSEPORT
socket options. Without getting into too many details, it allows steemd to have multiple connections on the same local socket in a safe manner. Well, the Linux subsystem is based on Linux kernel version 3.4.0 and SO_REUSEPORT
wasn't added to Linux until kernel version 3.9.0. Savvy Linux users will also know that kernel version 3.4.0 is in end of life support. This problem does not prevent steemd from working, but it does make the network code, specifically syncing the blockchain, much slower. I recommend to always keep a backup data directory around to avoid needed resyncs. However, the cli wallet does not rely on this and works great! Hopefully Microsoft will update the kernel version to 4.X sometime soon and all of these issues will be resolved.
Considering how tedious and difficult building Steem on Windows can be, this is a huge step forward for the Windows and open source communities to come together. Now, I am not expecting some miracle where those two groups of developers come together in harmony, but the open source OSX and the xcode seem to get along well enough, so I think this feature can and will revitalize Windows as an open development platform. Lastly, because Linux can be intimidating to new users, I believe having Bash on Windows will lower the barrier to entry for POSIX systems considerably. The impact of this in Computer Science education will be huge. I hope you enjoyed this guide.
Happy Coding!