Skip to content

Build Windows

HLXEasy edited this page Jun 13, 2021 · 13 revisions

Building Alias Wallet on Windows

The goal is to build the whole project using CMake. To do so, just follow the steps below.

Install required tools and libs

Git

Visual Studio 2019

  • Download from https://www.visualstudio.com/downloads/
  • Visual Studio 2019 Community Edition is enough.
  • Install at least these components:
    Required VS 2019 components
  • Important: If you're not on an English Windows, you need to install the Englisch language package too:
    VS 2019 language pack

Qt

Qt SDK can be found at https://www.qt.io/download-qt-installer. Here are the components from Qt SDK that we really need to compile Alias wallet application. Please keep Qt Creator selected as well! If MinGW is ticked you may untick that, unless you need it for other projects.

Select the components from the latest 5.12 release as this is an LTS line. With newer versions up to 5.15.1 (at the time of this writing), the build will work but we've spot issues with a duplicated task bar icon. So it's perfectly fine to stay on the latest 5.12 version.

Required Qt components

Also scroll down the list of components and under Developer and Designer Tools select CMake ... in the 64Bit version.

VCPKG

VCPKG is a Github project, you can find it at https://github.com/microsoft/vcpkg/

At first change to your desired directory and clone VCPKG Git repository:

D:\coding> git clone https://github.com/Microsoft/vcpkg.git

If you want to build only the x64 version of the wallet, you need to define the following environment variable:

VCPKG_DEFAULT_TRIPLET=x64-windows

That will disable the build of the x86 vcpkg packages.

Important: For all the next steps on vcpkg, you need to use Start menu > Visual Studio 2019 > x64 Native Tools Command Prompt for VS 2019 for all the next steps!

On x64 Native Tools Command Prompt for VS 2019 bootstrap the whole thing:

D:\coding> cd vcpkg
D:\coding\vcpkg> .\bootstrap-vcpkg.bat

After this, make vcpkg global available by executing the following cmd once as Administrator:

D:\coding\vcpkg> .\vcpkg.exe integrate install

Subsequent executions could be done with normal user permissions.

Now build and install the following packages. Patience please, this might take a long time:

D:\coding\vcpkg> .\vcpkg.exe install berkeleydb boost leveldb openssl

This command will build all required dependencies and depending on the power of your machine, it might take several hours.

In case you hit this build error on boost-math:

Building package boost-math[core]:x64-windows...
-- Downloading https://github.com/boostorg/math/archive/boost-1.72.0.tar.gz...
-- Extracting source D:/coding/vcpkg/downloads/boostorg-math-boost-1.72.0.tar.gz
CMake Error at scripts/cmake/vcpkg_extract_source_archive_ex.cmake:140 (file):
  file RENAME failed to rename

    D:/coding/vcpkg/buildtrees/boost-math/src/TEMP/math-boost-1.72.0

  to

    D:/coding/vcpkg/buildtrees/boost-math/src/ost-1.72.0-2786b6df16

  because: No such file or directory

Call Stack (most recent call first):
  scripts/cmake/vcpkg_from_github.cmake:139 (vcpkg_extract_source_archive_ex)
  ports/boost-math/portfile.cmake:5 (vcpkg_from_github)
  scripts/ports.cmake:76 (include)


Error: Building package boost-math:x64-windows failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: boost-math:x64-windows
  Vcpkg version: 2020.02.04-nohash

Additionally, attach any relevant sections from the log files above.

Copy the folder D:\coding\vcpkg\buildtrees\boost-math\src\TEMP\math-boost-1.72.0 one folder level up, rename it to ost-1.72.0-2786b6df16 and restart the build.

Install "unzip"

Download and install unzip. Make sure, it's installation folder is in the Path environment variable, so unzip can be called right from the cmdline.

Build Alias Wallet

Get sources

At first clone the Alias wallet repository:

D:\coding> git clone https://github.com/aliascash/alias-wallet 

Build on cmdline

Setup environment

You need to define the following environment variables:

  • QTDIR Pointing to the msvc directory within the Qt version to use.
  • VSDIR Pointing to the Visual Studio installation directory up to the directory of the used edition like community or enterprise.
  • VCPKGDIR Pointing to the root directory of your vcpkg clone.
  • CMAKEDIR Pointing to the bin folder on the CMake installation to use. The cmake binaries from Qt or vcpkg are perfectly fine, see example below.

Example:

QTDIR=C:\Qt\5.12.11\msvc2017_64
VSDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
VCPKGDIR=D:\coding\vcpkg
CMAKEDIR=C:\Qt\Tools\CMake_64\bin

If you're building for Win32 aka x86, you also need to define these variables:

  • QTDIR_x86 Pointing to the x86 msvc directory within the Qt version to use
  • CMAKEDIR_x86 Pointing to the bin folder on the CMake installation to use. Might work if you use the same CMake installation as defined with CMAKEDIR.

Example:

QTDIR_x86=C:\Qt\5.12.11\msvc2017
CMAKEDIR_x86=C:\Qt\Tools\CMake_32\bin

Build

To build, just open a cmd window, cd into the Git clone of alias-wallet repository and start the Windows build script:

D:\coding> scripts\cmake-build-win.bat

The build result could be found on the folder build/delivery/Alias inside of the Git clone.

To build the Win32 aka x86 version, just use the corresponding build script:

D:\coding> scripts\cmake-build-win-x86.bat

The build result could be found on the folder build-x86/delivery/Alias inside of the Git clone.

Go to File > Settings > Build, Execution, Deployment > Toolchains and make sure the toolchain is configured as on the following screenshot:

CLion Toolchain settings

Take special care of the path to the x86_64 version of C and C++ compiler. Additionally you should change the entry on Make: from nmake to jom! With jom you would have multithreaded builds, which is way faster than the singlethreaded nmake. If you installed vcpkg as described above, you can use jom.exe from there. The location is something like ...\vcpkg\downloads\tools\jom\jom-1.1.3\jom.exe on your vcpkg location.

Now open File > Settings > Build, Execution, Deployment > CMake, expand CMake options and put in the following content:

-DCMAKE_TOOLCHAIN_FILE=D:/coding/vcpkg/scripts/buildsystems/vcpkg.cmake
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER
-DENABLE_GUI=ON
-DQT_CMAKE_MODULE_PATH=C:\Qt\5.12.11\msvc2017_64\lib\cmake
-DCMAKE_BUILD_TYPE=Debug

CLion Toolchain settings

After that you could hit + to add another entry, now with Name and Build type Release. Put in the same content as above but with DCMAKE_BUILD_TYPE=Release. Now you're able to build a debug and a release version.

With a click on the "Build-Hammer", you can trigger the build:

Perform build

Library Notes

During the build the archives https://github.com/aliascash/resources/raw/master/resources/Tor.libraries.Win64.zip and https://github.com/aliascash/resources/raw/master/resources/VCRuntime.libraries.Win64.zip will be downloaded and extracted. They contain the Tor binary and it's libraries as well as some required runtime libraries to execute the wallet.

If you build the Win32 aka x86 version, the corresponding counterparts of these two archives will be used of course.