Difference between revisions of "Boost compilation"

From PeerFreedom Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
  
 
<pre>
 
<pre>
 +
 +
GOOD VERSION:
 +
 +
git clone --recursive https://github.com/boostorg/boost.git
 +
cd boost
 +
git checkout boost-1.72.0
 +
./bootstrap.sh
 +
./b2 headers -a -target-os=linux threading=multi --prefix=$HOME/.local  -j6 install
 +
 +
</pre>
 +
 +
<pre>
 +
 +
SO-SO VERSION
 +
  
 
git clone https://github.com/boostorg/boost.git
 
git clone https://github.com/boostorg/boost.git
 +
 +
or
 +
 +
git clone https://github.com/boostorg/boost.git --single-branch --branch boost-1.72.0
 +
 
better:
 
better:
 
https://www.boost.org/users/download/
 
https://www.boost.org/users/download/

Latest revision as of 22:49, 20 March 2020

Building boost

(Updated: 2019.06.15)

This is for normal build, on host linux, for target linux (native).

How to build boost:

Choose:

  • building boost for usage in C++14 mode
  • building boost for usage in C++17 mode (for programs that will be built in C++17 mode e.g. --std=c++17)

Based on that choice, change 17 to 14 in "cxxstd=17" and in directory name "boost-cpp17" if you use C++14.

Obtain sources of Boost, and checking out git submodules for boost-module-deps:


GOOD VERSION:

git clone --recursive https://github.com/boostorg/boost.git
cd boost
git checkout boost-1.72.0
./bootstrap.sh
./b2 headers -a -target-os=linux threading=multi --prefix=$HOME/.local  -j6 install


SO-SO VERSION


git clone https://github.com/boostorg/boost.git

or

git clone https://github.com/boostorg/boost.git --single-branch --branch boost-1.72.0

better:
https://www.boost.org/users/download/
cd boost # the cloned repository

git submodule update --init tools/build/
git submodule update --init tools/inspect

git submodule update --init ....(TODO).... list of boost-modules that are dependencies of the boost-modules that you want.......

## git submodule update --init libs/filesystem/
## git submodule update --init libs/asio/
## git submodule update --init libs/system/
## git submodule update --init libs/config/

Obtain list of some sub repositories using https://pdimov.github.io/boostdep-report/ for given Boost version (just copy the list from page). Also some other tools might be needed (TODO).

Start build:

./bootstrap.sh --without-icu

#to build complete boost
./b2    -q -a -target-os=linux threading=multi  --prefix=$HOME/.local  -j 6  cxxstd=17 install  # -j option should be set for number of cores limited by free RAM/disk space or -j 1 if not sure

Check: after doing such boost build, following directories will be created:

  • dir `~/.local/lib/` with files like `libboost_chrono-mt.a libboost_chrono-mt-d.a libboost_chrono-mt-d.so libboost_chrono-mt-d.so.1.68.0` (in case of boost 1.68) and more for other libraries besides chrono too
  • dir See~/.local/include/boost` with .hpp files including at least `asio.hpp` and few others

More libraries

For example to also add library boost::program_options you must

1) check out the submodule like

git submodule update --init libs/program_options

1b) check out dependencies of it, if needed (sometimes not needed)

2) build with adding also option

--with-program_options

so for example:

./b2    -q -a -target-os=linux threading=multi  --with-test --with-chrono --with-thread  --with-filesystem --with-system  --with-program_options    --prefix=$HOME/.local  -j 6  cxxstd=17 install

(this example assumes c++17 mode)

All libraries

To use all libraries, download all modules - so probably just all git-submodules in git, and then build without any --with-... argument at all.

Compiling with the local Boost

export BOOST_ROOT="$HOME/.local/"
cmake 
make

Local Boost in QT

This change in QT could be in various places (if it is needed, if not using system boost).

  • edit existing Kits, and add custom cmake option there:
    • in given Kit, do: CMake Configuration' - edit it - append line "BOOST_ROOT:INTERNAL=/home/rafalcode/local/boost-cpp17/" it must be ```:INTERNEL``` when it was STRING then it was nor working for me (blacksmith 201908, debian 9, local boost 8.x, in C++17 mode)
    • Pfp localboost in qt kit.png
  • or edit program environment
  • or edit program cmake (though above changes should do it)

Sometimes it still failed to find boost, e.g. when in Debug target in QT, not clear why.

See also complete example in Qt - Qtcreator chapter "Build Settings Complete Example"

Also LD_LIBRARY_PATH

This is probably NOT related (but is more about using custom compiler and custom libraries coming with it)

For QT: "Projects"→"Run"→"Run Environment"→"Add": variable is: LD_LIBRARY_PATH, value is /home/Foo/.local/lib

You might need to set LD_LIBRARY_PATH to have boost objects, and gcc objects.

Building boost for Windows cross compilation

echo "using gcc : 9.1.1 : <mingw install path>/bin/x86_64-w64-mingw32-g++ ;" > user-config.jam
./bootstrap.sh --without-icu
./b2 threading=multi --user-config=user-config.jam --with-chrono --with-thread --with-filesystem --with-system toolset=gcc -j 2 target-os=windows address-model=64 architecture=x86 variant=release