Wednesday, 2 May 2018

Building Boost 1.67.0 on MSYS2 MinGW 64 bit

This walkthrough explains how to build Boost 1.67.0 from sources on MSYS2, without using system packages.

1) Build ICU

  1. ICU is used by Boost Regex and Locale. Download the sources for ICU 58.
  2. Unzip it and enter the source directory.
  3. ./runConfigureICU MinGW
  4. make
  5. Enter the lib directory. Make a copy of all the files and keep it in a new subdirectory here, say original and rename the files: icudt58.dll -> icudata.dll, icuin58.dll -> icui18n.dll, icuuc58.dll -> icuuc.dll
  6. Go back to the source directory. Make a directory called include and copy the following directories, merging them when prompted: common/unicode, i18n/unicode. The include directory will have a single unicode directory, which contains the several copied header files.

2) Install Python27 (64 bit) on Windows

Download the installer and run it. Make sure to get the 64 bit version. Then, copy python27.dll from C:\Windows\system32 to C:\Python27\libs

3) Bootstrap boost

./bootstrap.sh --with-toolset=gcc --with-icu=C:/msys64/.../icu4c-58_2-src/source --with-python-root=C:/Python27

4) Build all libraries except python and locale

./b2 --reconfigure --without-python --without-locale toolset=gcc variant=debug link=shared threading=multi runtime-link=shared address-model=64

During the configure step, look for the output "has_icu builds... no". Halt the configure step here (Ctrl-C) and copy the following files to boost_1_67_0\bin.v2\libs\regex\build\gcc-7.3.0\debug:
  • C:\msys64\mingw64\bin\libgcc_s_seh-1.dll
  • C:\msys64\mingw64\bin\libwinpthread-1.dll
  • icudt58.dll
  • icuin58.dll
  • icuuc58.dll
These files are dynamically loaded by the test executable. Then run the command again. The expected output should be something like this:

Performing configuration checks

- default address-model : 64-bit
- default architecture : x86

Building the Boost C++ Libraries.

- symlinks supported : no
- junctions supported : yes
- hardlinks supported : yes
- C++11 mutex : yes
- Boost.Config Feature Check: cxx11_lambdas : yes
- Boost.Config Feature Check: cxx11_noexcept : yes
- Boost.Config Feature Check: cxx11_nullptr : yes
- Boost.Config Feature Check: cxx11_rvalue_references : yes
- Boost.Config Feature Check: cxx11_template_aliases : yes
- Boost.Config Feature Check: cxx11_thread_local : no
- Boost.Config Feature Check: cxx11_variadic_templates : yes
- Boost.Config Feature Check: cxx11_auto_declarations : yes
- Boost.Config Feature Check: cxx11_constexpr : yes
- Boost.Config Feature Check: cxx11_defaulted_functions : yes
- Boost.Config Feature Check: cxx11_final : yes
- Boost.Config Feature Check: cxx11_hdr_mutex : yes
- Boost.Config Feature Check: cxx11_hdr_regex : yes
- Boost.Config Feature Check: cxx11_hdr_tuple : yes
- has_icu builds : yes
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
- zlib : yes
- bzip2 : yes
- lzma : yes
- native-atomic-int32-supported : yes
- message-compiler : no
- native-syslog-supported : no
- pthread-supports-robust-mutexes : no
- compiler-supports-visibility : yes
- compiler-supports-ssse3 : yes
- compiler-supports-avx2 : yes
- gcc visibility : yes
- long double support : yes
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
- libbacktrace builds : no
- addr2line builds : no
- WinDbg builds : yes
- WinDbgCached builds : no
- BOOST_COMP_GNUC >= 4.3.0 : no

Component configuration:

- atomic : building
- chrono : building
- container : building
- context : building
- contract : building
- coroutine : building
- date_time : building
- exception : building
- fiber : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : not building
- log : building
- math : building
- mpi : building
- program_options : building
- python : not building
- random : building
- regex : building
- serialization : building
- signals : building
- stacktrace : building
- system : building
- test : building
- thread : building
- timer : building
- type_erasure : building
- wave : building

...patience...
...patience...

---snip---

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

C:\msys64\home\user\boost_1_67_0

The following directory should be added to linker library paths:

C:\msys64\home\user\boost_1_67_0\stage\lib


5) Build boost locale

./b2 --reconfigure --with-locale toolset=gcc variant=debug link=shared threading=multi runtime-link=shared address-model=64 boost.locale.iconv=off -sICU_PATH=C:/msys64/.../icu4c-58_2-src/source

The iconv=offflag is to ensure that ICU is being used.

6) Build boost python

./b2 cxxflags="-DMS_WIN64 -D_hypot=hypot" --reconfigure --with-python toolset=gcc variant=debug link=shared threading=multi runtime-link=shared address-model=64

The preprocessor definitions have something to do with this issue.

7) Done!

The include path will be C:\msys64\home\user\boost_1_67_0. The dlls are in C:\msys64\home\user\boost_1_67_0\stage\lib.

No comments:

Post a Comment