【问题标题】:How to set up boost easily with clang with brew installation on OS X如何在 OS X 上通过 brew 安装使用 clang 轻松设置 boost
【发布时间】:2016-03-30 05:48:01
【问题描述】:

我在 OS X 上通过 brew 安装了 boost 1.60,El Capitan 10.11.4

> brew install boost
==> Downloading https://homebrew.bintray.com/bottles/boost-1.60.0_1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.60.0_1.el_capitan.bottle.tar.gz
????  /usr/local/Cellar/boost/1.60.0_1: 11,139 files, 436.0M

但是,在我的 clang 工具链中使用 <boost/...> 并不容易。它根本找不到 boost 目录。

> make
Scanning dependencies of target foo
[ 50%] Building CXX object CMakeFiles/foo.dir/foo.cpp.o
foo.cpp:16:10: fatal error: 'boost/type_index.hpp' file not found
#include <boost/type_index.hpp>
         ^
1 error generated.

我知道我必须设置一些环境变量或添加-I。但我想看看解决这个问题的最佳方法。

【问题讨论】:

  • /usr/local/Cellar' in your $PATH`?输入 echo $PATH 找出

标签: c++ boost clang homebrew


【解决方案1】:

从描述中,我认为您的问题有两种可能的解决方案

  1. 在本地某处安装 boost 并将 BOOST_ROOT 变量设置为该文件夹。

  2. 将 boost 的包含和库变量更新到相应的 boost brew 目录。

以下是您需要添加到 CMakeLists.txt 中的代码段

set(Boost_NO_SYSTEM_PATHS TRUE)
if (Boost_NO_SYSTEM_PATHS)
  set(BOOST_ROOT "${ROOT_DIR}/")
  set(BOOST_INCLUDE_DIRS "${ROOT_DIR}/include")
  set(BOOST_LIBRARY_DIRS "${ROOT_DIR}/lib")
endif (Boost_NO_SYSTEM_PATHS)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-31
    • 2015-11-14
    • 2011-04-20
    • 2014-10-17
    • 1970-01-01
    • 2014-11-19
    • 1970-01-01
    相关资源
    最近更新 更多