【问题标题】:CMake cannot find Boost on OS X with brewCMake 无法使用 brew 在 OS X 上找到 Boost
【发布时间】:2014-11-19 10:01:26
【问题描述】:

我正在尝试使用 CMake 编译另一个库,它需要 Boost。

我已经在 OS X 10.10 Yosemite 上使用 brew 安装了 CMake 和 Boost,但 CMake 拒绝找到它。 Boost位于/usr/local/Cellar/boost/1.55.0_2

我尝试了以下方法:

  • 使用上述路径设置-DBoost_DIR-DBOOST_ROOT
  • 使用上述路径设置-DBoost_INCLUDE_DIR-DBOOST_INCLUDEDIR + /include
  • 在 CMakeLists.txt 文件中设置所有这些选项
  • 自己编译 Boost,并将上述变量指向我自己的构建
  • 针对同一问题尝试类似的解决方案hereherehere。我发现在 OS X 上提到 brew 的唯一答案是 this one,同样的解决方案对我不起作用。

为什么 CMake 公然无视我的指示? :(

编辑: CMake output from -DBoost_DEBUG=ON

【问题讨论】:

  • 你能用-DBoost_DEBUG=ON重新运行cmake并发布输出吗?
  • @Fraser 完成,问题中的链接
  • 能否请您提供 Boost.System 库的完整路径(包括文件名)?
  • 我也有同样的问题。你找到解决办法了吗?
  • 当我使用 brew install boost 安装 boost 时遇到了这个问题。而是使用brew install boost-python

标签: macos boost cmake homebrew


【解决方案1】:

我找到了一个单独的自制程序包boost-python。安装后,CMake 确实找到了 Boost:

brew install boost-python

给我

> mkdir build ; ( cd build ; cmake .. )
-- The C compiler identification is AppleClang 6.0.0.6000056
-- The CXX compiler identification is AppleClang 6.0.0.6000056
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PythonInterp: /usr/local/bin/python (found version "2.7.9")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.5")
-- Boost version: 1.56.0
-- Found the following Boost libraries:
--   python
-- Configuring done
-- Generating done

(我的链接有问题,但这是另一回事)

【讨论】:

  • 未能找到stackoverflow.com/questions/33653001/…后面的boost(对于boost:python和python3)
  • 运行 brew install boost-python 导致错误“错误:boost-python 已被禁用,因为它没有构建!”。但是brew install boost 为我解决了这个问题。
【解决方案2】:

我在使用 C++/Python/Boost/CMake 编译某些东西时也遇到了问题(具体来说,我正在尝试构建 https://github.com/mapillary/OpenSfM)。

我遇到了这样的错误

Linking CXX shared library .../OpenSfM/opensfm/csfm.so
Undefined symbols for architecture x86_64:
  "boost::python::instance_holder::deallocate(_object*, void*)", referenced from:
Undefined symbols for architecture x86_64:
"boost::python::instance_holder::deallocate(_object*, void*)", referenced from:
...

受上述评论的启发,我试图找到这个神话般的“boost-python”,但它并不存在。相反,我最终使用自制软件用 python 重新安装了正常的 boost。

brew install boost --with-python

那行得通。 CMake 现在可以找到 boost 和它需要的任何 python boost 东西,并且编译成功。

【讨论】:

  • 美丽。谢谢!
  • Warning: boost@1.59: this formula has no --with-python option so it will be ignored!
  • brew install boost --with-python 似乎是一个临时解决方案,我们回到brew install boost-python
【解决方案3】:

在我的情况下,将 cmake 和 boost 升级到最新版本解决了这个问题

brew upgrade boost cmake

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-23
    • 2020-10-17
    • 2014-08-02
    相关资源
    最近更新 更多