CMake无法使用brew在OS X上找到Boost

tta*_*rik 16 macos homebrew boost cmake

我正在尝试使用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,并将上面的变量指向我自己的构建
  • 在这里,这里这里尝试类似的解决方案来解决同样的问题.我发现在OS X上提到brew的唯一答案是这个,同样的解决方案对我不起作用.

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

编辑: 从-DBoost_DEBUG = ON的CMake输出

ach*_*imh 11

我发现了一个单独的自制软件包boost-python.安装后,CMake确实找到了Boost:

brew install boost-python
Run Code Online (Sandbox Code Playgroud)

给我

> 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
Run Code Online (Sandbox Code Playgroud)

(我有链接问题,但这是另一个故事)


小智 5

我在使用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:
...
Run Code Online (Sandbox Code Playgroud)

受上述评论的启发,我试图找到这个神秘的"boost-python",但它并不存在.相反,我结束了使用自制软件重新安装python正常的提升.

brew install boost --with-python
Run Code Online (Sandbox Code Playgroud)

那很有效.CMake现在可以找到提升和任何python提升所需的东西,并且编译成功.

  • `警告:boost@1.59:这个公式没有--with-python选项,所以它会被忽略!` (4认同)
  • `brew install boost --with-python ` 似乎是一个临时解决方案,我们又回到了 `brew install boost-python` (2认同)