Skip to content
Jack Gerrits edited this page Dec 18, 2020 · 74 revisions

Getting started > [Dependencies] > Building > Installing > Tutorial


Before building VW from source the following dependencies must be satisfied.

Ubuntu

Ensure you have the source:

git clone --recursive https://github.com/VowpalWabbit/vowpal_wabbit.git
cd vowpal_wabbit

Get dependencies:

# Core
sudo apt install libboost-dev libboost-thread-dev libboost-program-options-dev libboost-system-dev libboost-math-dev libboost-test-dev zlib1g-dev cmake g++

# Install flatbuffers
wget https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz
tar -xzf v1.12.0.tar.gz
cd flatbuffers-1.12.0
mkdir build_dir
cd build_dir
cmake -G "Unix Makefiles" -DFLATBUFFERS_BUILD_TESTS=Off -DFLATBUFFERS_INSTALL=On -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_FLATHASH=Off ..
make install -j$(nproc)

# Optional: test
pip install six

# Optional: Python bindings
sudo apt install libboost-python-dev

# Optional: Java, Ubuntu 16.04 or newer
sudo apt install default-jdk

Note: If using WSL and you cloned the repo in Windows you will need to run git submodule update --init --recursive before running cmake. Otherwise the submodule will be downloaded with git in bash and the line endings will break git commands from Windows. Otherwise, submodules are automatically downloaded by cmake.

If attempting to build on WSL on an NTFS drive, also be sure that the drive is mounted with the "metadata" option, or cmake will not complete successfully. (See: https://github.com/microsoft/WSL/issues/4257#issuecomment-507799403)

Next step: building on Linux

MacOS

Ensure you have the source:

git clone --recursive https://github.com/VowpalWabbit/vowpal_wabbit.git
cd vowpal_wabbit

HomeBrew

brew install cmake
brew install boost

brew install flatbuffers

# If you want to statically link VW
brew install zlib

# If you want to build with python 2 support
brew install boost-python

# If you want to build with python 3 support
brew install boost-python3

MacPorts

# Build Boost for Mac OS X 10.8 and below
port install boost +no_single -no_static +openmpi +python27 configure.cxx_stdlib=libc++ configure.cxx=clang++ flatbuffers

# Build Boost for Mac OS X 10.9 and above
port install boost +no_single -no_static +openmpi +python27 flatbuffers

The rest of the Linux instructions should apply to MacOS too.

Next step: building on Linux

Windows

Ensure you have the source:

git clone --recursive https://github.com/VowpalWabbit/vowpal_wabbit.git
cd vowpal_wabbit
  • Either Visual Studio 2017 or 2019 can be used, VS2019 is recommended
  • Visual Studio 2017 (v141) toolset must be installed if using VS 2019
  • 10.0.16299.0 Windows 10 SDK must be installed
  • Nuget is used for other dependencies. Open vowpalwabbit/vw.sln in Visual Studio and restore Nuget dependencies

If using Visual Studio 2017 (v141) flatbuffers can be installed via Vcpkg by running:

vcpkg install flatbuffers:x64-windows
  • Set VcpkgIntegration environment variable to vcpkg.targets file on your machine. Example: VcpkgIntegration=<vcpkg_root>\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets
  • Add the flatbuffers tool directory to your PATH: <vcpkg_root>\installed\x64-windows\tools\flatbuffers OR set flatcPath environment variable to the flatc.exe on your machine. Example: flatcPath=<vcpkg_root>\installed\x64-windows\tools\flatbuffers\flatc.exe

If using Visual Studio 2019 or if Visual Studio 2019 (v142) is installed then additional steps will need to be taken to avoid linker errors due to version incompatibilities. Flatbuffers will need to be installed via Vcpkg using v141:

  • From the triplets directory in your Vcpkg installation (e.g. <vcpkg_root>\triplets)
cp x64-windows.cmake x64-windows-v141.cmake
  • Set the VCPKG_PLATFORM_TOOLSET variable to v141 by adding set(VCPKG_PLATFORM_TOOLSET v141) to the new x64-windows-v141.cmake file
vcpkg install flatbuffers:x64-windows-v141
  • Set VcpkgIntegration environment variable to vcpkg.targets file on your machine. Example: VcpkgIntegration=<vcpkg_root>\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets
  • Set VcpkgPlatformToolset environment variable to v141
  • Add the flatbuffers tool directory to your PATH: <vcpkg_root>\installed\x64-windows-v141\tools\flatbuffers OR set flatcPath environment variable to the flatc.exe on your machine. Example: flatcPath=<vcpkg_root>\installed\x64-windows-v141\tools\flatbuffers\flatc.exe

Next step: building on Windows

Experimental: CMake build system on Windows

Note: The CSharp projects are not yet converted to CMake for Windows. So the CMake generated solution is only for C++ projects for the time being. For this reason the existing solution can not yet be deprecated.

When using CMake for Windows, dependencies are easily managed through Vcpkg. Install the following dependencies with Vcpkg:

vcpkg --triplet x64-windows install zlib boost-system boost-program-options boost-test boost-align boost-foreach boost-python boost-math python3

Next step: building on Windows with CMake

Clone this wiki locally