Skip to content

Instantly share code, notes, and snippets.

@amir-saniyan
Created February 13, 2020 17:47
Show Gist options
  • Save amir-saniyan/3d6eabcbb83c46069349c0209a9f19df to your computer and use it in GitHub Desktop.
Save amir-saniyan/3d6eabcbb83c46069349c0209a9f19df to your computer and use it in GitHub Desktop.

Build Boost

Ubuntu 18.04 Prerequisites

$ sudo apt install build-essential pkg-config cmake

Windows Prerequisites

  • Install MSYS2 (https://www.msys2.org)
  • Open Start Menu > MSYS2 64bit > MSYS2 MSYS and run the following commands:
$ pacman -Syu
$ ########## Close terminal window. ##########
$ pacman -Su
$ pacman -S base-devel
$ pacman -S mingw-w64-i686-toolchain
$ pacman -S mingw-w64-x86_64-toolchain
$ pacman -S mingw-w64-i686-cmake
$ pacman -S mingw-w64-x86_64-cmake
  • To compile 32-bit version: Start Menu > MSYS2 64bit > MSYS2 MinGW 32-bit
  • To compile 64-bit version: Start Menu > MSYS2 64bit > MSYS2 MinGW 64-bit
  • Dependencies:
    • ibstdc++-6.dll
    • libgcc_s_dw2-1.dll (for x86)
    • libgcc_s_seh-1.dll (for x64)
    • libwinpthread-1.dll
    • libbz2-1.dll
    • libiconv-2.dll
    • liblzma-5.dll
    • libzstd.dll
    • zlib1.dll

Compilation

For dynamic loading compilation:

$ cd boost_x_y_z
$ ./bootstrap.sh
$ ./b2 variant=release link=shared threading=multi hardcode-dll-paths=true dll-path=\$ORIGIN install --prefix=$HOME/boost

For static loading compilation:

$ cd boost_x_y_z
$ ./bootstrap.sh
$ ./b2 variant=release link=static cflags=-fPIC cxxflags=-fPIC threading=multi install --prefix=$HOME/boost
  • CMake: set(Boost_USE_STATIC_LIBS ON)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment