Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build Boost from github?

Tags:

boost

I git clone boost latest source code on master branch from Github. I tried to build it but failed,

$ ./bootstrap.sh 
  ./bootstrap.sh: line 188: ./tools/build/src/engine/build.sh: No such file or directory
  -n Building Boost.Build engine with toolset ... 

  Failed to build Boost.Build build engine
  Consult 'bootstrap.log' for more details

The content of bootstrap.log

1 ./bootstrap.sh: line 218: cd: ./tools/build/src/engine: No such file or directory


Question:
I understand there is no ./tools/build/src/engine, how do I solve this? I also noted that

-n Building Boost.Build engine with toolset ...

however, bootstrap.sh doesn't have -n option.


My develop environment: MacOS X10.9 Xcode5.1

like image 626
user001 Avatar asked Apr 16 '14 04:04

user001


3 Answers

The current documentation for building directly from the Git repo is at Getting Started. Basically there are some additional steps to create the include directory tree and to run the build itself. NOTE, please also make sure you use the b2 command from the cloned repo. Not whatever you might have prebuilt in your system.

like image 156
GrafikRobot Avatar answered Oct 13 '22 21:10

GrafikRobot


To checkout latest version of Boost libraries from GitHub do the following:

  • Checkout Boost super-project (only minimum required): git clone --single-branch --branch master --depth=1 https://github.com/boostorg/boost.git.
  • cd boost/
  • Checkout all the submodules (only minimum required): git submodule update --init --recursive --remote --no-fetch --depth=1.

If an error like following occured:

Cloning into 'libs/predef'...
remote: Counting objects: 243, done.
remote: Compressing objects: 100% (163/163), done.
remote: Total 243 (delta 128), reused 126 (delta 70), pack-reused 0
Receiving objects: 100% (243/243), 142.82 KiB | 209.00 KiB/s, done.
Resolving deltas: 100% (128/128), done.
Checking connectivity... done.
fatal: Needed a single revision
Unable to find current origin/master revision in submodule path 'libs/predef'

then use script (reget.bash):

#! /usr/bin/env bash -vex

rm -rf $3/$1 .git/modules/$1
git clone --depth=1 --branch=$2 --single-branch --separate-git-dir .git/modules/$1 https://github.com/boostorg/$1 $3/$1

where $1 is predef, $2 is master, $3 is libs, i.e. run bash reget.bash predef master libs.

An error can occur many times for different submodules, just use above script to clean up unrecoverable git error and to checkout latest commit for failed submodule. Then reuse git submodule update --init --recursive --remote --no-fetch --depth=1.

After complete checking out of all the submodules, build b2 executable. For clang it looks like:

export CC=clang
export CFLAGS="-march=native -Ofast"
export CXX=clang++
export CXXFLAGS="-march=native -Ofast"

bash bootstrap.sh --with-toolset=clang

You have obtained b2 executable. Use it to build whole Boost:

sudo ./b2 -j`nproc` toolset=clang --build-dir=/tmp/build-boost --without-mpi install

ADDITIONAL:

If you want to clone only HEAD of boost itself and HEADS of all the its submodules, then you may use following Lua script (tested on https://github.com/boostorg/boost.git repository):

-- mkdir boost ; cd boost ; lua ../git-submodules-clone-HEAD.lua https://github.com/boostorg/boost.git .
local module_url = arg[1] or 'https://github.com/boostorg/boost.git'
local module = arg[2] or module_url:match('.+/([_%d%a]+)%.git')
local branch = arg[3] or 'master'
function execute(command)
    print('# ' .. command)
    return os.execute(command)
end
-- execute('rm -rf ' .. module)
if not execute('git clone --single-branch --branch master --depth=1 ' .. module_url .. ' ' .. module) then
    io.stderr:write('can\'t clone repository from ' .. module_url .. ' to ' .. module .. '\n')
    return 1
end
-- cd $module ; git submodule update --init --recursive --remote --no-fetch --depth=1
execute('mkdir -p ' .. module .. '/.git/modules')
assert(io.input(module .. '/.gitmodules'))
local lines = {}
for line in io.lines() do
    table.insert(lines, line)
end
local submodule
local path
local submodule_url
for _, line in ipairs(lines) do
    local submodule_ = line:match('^%[submodule %"([_%d%a]-)%"%]$')
    if submodule_ then
    submodule = submodule_
    path = nil
    submodule_url = nil
    else
    local path_ = line:match('^%s*path = (.+)$')
    if path_ then
        path = path_
    else
        submodule_url = line:match('^%s*url = (.+)$')
    end
    if submodule and path and submodule_url then
        -- execute('rm -rf ' .. path)
        local git_dir = module .. '/.git/modules/' .. path:match('^.-/(.+)$')
        -- execute('rm -rf ' .. git_dir)
        execute('mkdir -p $(dirname "' .. git_dir .. '")')
        if not execute('git clone --depth=1 --single-branch --branch=' .. branch .. ' --separate-git-dir ' .. git_dir .. ' ' .. module_url .. '/' .. submodule_url .. ' ' .. module .. '/' .. path) then
            io.stderr:write('can\'t clone submodule ' .. submodule)
            return 1
        end
        path = nil
        submodule_url = nil
    end
    end
end
like image 23
Tomilov Anatoliy Avatar answered Oct 13 '22 21:10

Tomilov Anatoliy


I really missed some important part of the documentation: .\b2 headers. So here follows all I've done to build thread, chrono and date-time, both release and debug, both static and shared, from version 1.60.0, cloning from the GitHub repo (in a Windows machine):

git clone --recursive https://github.com/boostorg/boost.git
cd boost
git checkout boost-1.60.0
git submodule update
bootstrap.bat
.\b2.exe headers
.\b2.exe variant=release,debug link=static,shared address-model=32 architecture=x86 --with-thread --with-chrono --with-date_time --stagedir=stage\win32 stage
.\b2.exe variant=release,debug link=static,shared address-model=64 architecture=x86 --with-thread --with-chrono --with-date_time --stagedir=stage\x64 stage

Don't forget the:

.\b2.exe headers
like image 27
Tarc Avatar answered Oct 13 '22 22:10

Tarc