【问题标题】:How do I build Boost from github?如何从 github 构建 Boost?
【发布时间】:2014-04-16 04:51:02
【问题描述】:

我在 Github 的 master 分支上 git clone boost 最新源代码。我尝试构建它但失败了,

$ ./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

bootstrap.log的内容

1 ./bootstrap.sh: line 218: cd: ./tools/build/src/engine: 没有这样的文件或目录


问题:
我知道没有./tools/build/src/engine,我该如何解决?我还注意到

-n 使用工具集构建 Boost.Build 引擎 ...

但是,bootstrap.sh 没有 -n 选项。


我的开发环境: MacOS X10.9Xcode5.1

【问题讨论】:

  • How to install Modular Boost? 的可能重复项
  • @sehe,谢谢。我在那篇帖子上尝试了你的答案,我得到了错误“pathspec'boost-1.55.0'与git已知的任何文件都不匹配。”而且,我可以构建 boost-1.55,但是,我需要构建最新的代码。
  • 这仅仅意味着你所在的仓库没有分支/标签名称boost-1.55。当然,如果您想要一个不同的分支,只需要求它,例如BOOST_VER=develop 将所有子项目切换到develop 分支。但是,如果 boost-1.55 不是 boost-1.55.0 的拼写错误并且您的克隆没有,我建议检查您的克隆(根据需要更新或重新克隆?)

标签: boost


【解决方案1】:

直接从 Git 存储库构建的当前文档位于 Getting Started。基本上有一些额外的步骤来创建包含目录树并运行构建本身。注意,还请确保您使用克隆仓库中的b2 命令。不是您可能在系统中预先构建的任何内容。

【讨论】:

  • 感谢@GrafikRobot,我按照链接构建了我的最新版本以用于提升。
  • 如何克隆特定模块而不是每个模块?
  • @LeFlou 只是不要做一个 recusive git clone。然后针对特定模块执行: git submodule update --init "libs/whatever"
【解决方案2】:

要从 GitHub 签出最新版本的 Boost 库,请执行以下操作:

  • 结帐 Boost 超级项目(最低要求):git clone --single-branch --branch master --depth=1 https://github.com/boostorg/boost.git
  • cd boost/
  • 检查所有子模块(仅需要最低要求):git submodule update --init --recursive --remote --no-fetch --depth=1

如果出现如下错误:

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'

然后使用脚本(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

其中$1predef$2master$3libs,即运行bash reget.bash predef master libs

不同的子模块可能会发生多次错误,只需使用上述脚本清理不可恢复的 git 错误并检查失败子模块的最新提交即可。然后重用git submodule update --init --recursive --remote --no-fetch --depth=1

检查完所有子模块后,构建b2 可执行文件。对于 clang,它看起来像:

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

bash bootstrap.sh --with-toolset=clang

您已获得b2 可执行文件。用它来构建整个Boost

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

附加:

如果您只想克隆 boost 本身的 HEAD 及其所有子模块的 HEADS,那么您可以使用以下 Lua 脚本(在https://github.com/boostorg/boost.git 仓库):

-- 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

【讨论】:

    【解决方案3】:

    我真的错过了文档的一些重要部分:.\b2 headers。因此,这里遵循我为构建 threadchronodate-time 所做的一切,从 1.60.0 版本开始,从 GitHub 存储库克隆(在 Windows 机器中),发布和调试,静态和共享:

    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
    

    别忘了:

    .\b2.exe headers
    

    【讨论】:

      【解决方案4】:

      我遇到了完全相同的问题。最短的答案是缺少 tools/build.git。 https://github.com/boostorg/build.git。只需在目录上执行git submodule update --recursive --remote。这将下载缺少的工具/构建和其他依赖目录。

      注意,除了构建子模块之外,还会相应地下载更多的子模块。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-30
        • 2021-03-18
        • 2013-08-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-15
        • 1970-01-01
        相关资源
        最近更新 更多