Skip to content

Building on Windows

AronVanAmmers edited this page Oct 2, 2014 · 25 revisions

Cross-compiling with MinGW64

Create fresh ubuntu 14.04 (Trusty Tahr) VM:

http://cdimage.ubuntu.com/trusty/daily-live/current/trusty-desktop-amd64.iso

See http://ubuntu.com for more details on installing Ubuntu.

Set up a crossbuild environment as described in Setting-up-prebuilt-crossbuild-environment, or for full instructions on how to set up the environment from scratch, Setting-up-crossbuild-environment-from-scratch.

Note: As of (at least) 19.09.2014 cross compiling seems to be broken, both when compiling everything yourself and with the prebuilt libs. This is because cpp-ethereum now uses/looks for Qt5Webkit(Config) which is disabled by qmake/configure but also implicitly disabled because qt is supposed to be built statically.

Build cpp-ethereum:

$ git clone https://github.com/ethereum/cpp-ethereum
$ mkdir cpp-ethereum-build
$ cd cpp-ethereum-build
$ cmake ../cpp-ethereum -DTARGET_PLATFORM=w64
$ make
$ cd ..

Compiling with Visual Studio Express 2013

Initial configuration and build

Ensure you have installed:

  • Visual Studio Express 2013 for Windows Desktop. VS 2013 WD is a minimum as cpp-ethereum uses languages features not supported in 2012. The Professional edition should also work, but this has not been tested.
  • Windows 7 SDK or Windows 8 SDK - for files like winsock2.h and gdi32.lib
  • Python. Needed to compile Qt.
  • Perl. Needed to compile Qt (they suggest ActiveState Perl). Hint: Make sure that Perl is added to the path in front of git since that ships an outdated version (Perl 5.8), which will cause the scripts to fail. (tested but also says so on Qt website)
  • Ruby. Needed to compile Qt.
  • Git for Windows 1.9.0+. This includes (among other things) git and curl which are needed for bootstrap.sh.
  • Make sure a newer perl installation is on the PATH, otherwise QtWebkit will fail to compile when it picks up the git installed perl. bootstrap.sh should (hopefully) automatically juggle the paths correctly.
  • Note that msysgit version 1.9.4-preview20140815 (the current one at moment of writing) includes a bug which prevents git svn from working, breaking the bootstrap script. The bug report contains a workaround using rebase.
  • 7-Zip.

Ensure 7z.exe, perl.exe, python.exe and ruby.exe have been added to the PATH.

Execute the following commands within a Git Bash shell to download and compile Ethereum and all it's dependencies to the current directory:

$ curl -o bootstrap.sh -L https://raw.github.com/ethereum/cpp-ethereum/develop/windows/bootstrap.sh
$ ./bootstrap.sh

This will fetch about 300MB of sources and take many hours to compile (mostly Qt). The resulting binaries are placed in the directory _binaries.

It should also be possible to compile and debug by opening Ethereum.sln with Visual Studio 2013.

Executing bootstrap.sh again should only be necessary if in future Ethereum requires additional libaries that weren't compiled in the previous run. Note that bootstrap.sh has been heavily updated since 22/04/2013, so a clean run is required from earlier versions. If Qt apps are not required, then it should be possible to edit bootstrap.sh to skip this stuff and save a lot of time.

Fresh builds

After setting up the dependencies and running your first successful build, you can make a fresh build from the latest code much faster by just fetching the new code and rebuilding.

  1. In the directory cpp-ethereum, run the command git pull.
  2. Run bootstrap.sh.

Troubleshooting

Errors about missing files or "unresolved external symbol"

The project files for Visual Studio (*.vcxproj), which are all located in the windows directory, list which files are to be included in the build. The primary way of building cpp-ethereum uses CMake, and the Visual Studio files are updated manually after every add or delete of a file. Differences can arise between the files that should be built and the files in the VS project files, breaking the build for Visual Studio until the project files are updated.

  • When a file has been deleted, but the .vcxproj file still refers to it, building will show a "file not found" type error.
  • When a file has been added, but the .vcxproj file doesn't contain it, building will show "unresolved external symbol" type errors.

As a workaround to get a succesful build, correct the .vcxproj files in your version so they match the current files.

The following git commands are helpful to see which files have recently been recently added or deleted. Execute them from the git command prompt in the cpp-ethereum directory.

git log --diff-filter=D --summary | head -n 50
git log --diff-filter=A --summary | head -n 50

Matching the date/times of the deletes/creates with the date that the build got broken on the build server is helpful to see which files need to be updated in the .vcxproj files.

For example if the git command shows that a file libethereum/EthereumHost.cpp has been added, but LibEthereum.vcxproj doesn't contain it, it should be added with a line like:

(...)
  <ItemGroup>
(...)
    <ClCompile Include="..\libethereum\EthereumHost.cpp" />
(...)
Clone this wiki locally