c++ - Boost 不再适用于 Mac El Capitan 上的 Homebrew

标签 c++ macos boost homebrew osx-elcapitan

我刚刚从 Yosemite 更新到 El Capitan,它破坏了我的一个依赖 Boost 的 C++ 程序。每当我尝试编译时,都会出现以下错误:

fatal error: 'boost/timer/timer.hpp' file not found
#include <boost/timer/timer.hpp>

fatal error: 'boost/program_options.hpp' file not found
#include "boost/program_options.hpp"

我一直在用正确的标志编译它,并且之前它运行良好:

-lboost_timer-mt \
-lboost_program_options-mt \

我已经按照 home-brew 的说明来 chown/usr/local,运行 brew doctor 和 brew update,甚至 brew reinstall boost。我还检查了 timer.hpp 是否存在于/usr/local/include/boost 中。

更新跑:clang++ -E -x c++ - -v

Apple LLVM version 7.0.0 (clang-700.0.72) Target: x86_64-apple-darwin15.0.0 Thread model: posix  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
    -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.2 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
    -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /usr/local/lib -ferror-limit 19 -fmessage-length 272 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0
    -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ - clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target x86_64-apple-darwin15.0.0 ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/v1" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
    #include "..." search starts here:
    #include <...> search starts here:  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks (framework directory) End of search list.
    # 1 "<stdin>"
    # 1 "<built-in>" 1
    # 1 "<built-in>" 3
    # 332 "<built-in>" 3
    # 1 "<command line>" 1
    # 1 "<built-in>" 2
    # 1 "<stdin>" 2

最佳答案

您应该使用 xcode-select --install 安装 Xcode 命令行工具,以获得默认搜索/usr/local 的 clang 版本。否则,您将使用 Xcode 提供的版本,它只搜索 OS X SDK 路径。 (/usr/bin/gcc 和/usr/bin/g++ 都调用 clang,实际上并不是 gcc 的版本。)

关于c++ - Boost 不再适用于 Mac El Capitan 上的 Homebrew,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32898887/

相关文章:

C++ 非常小的 float ,精度

c++ - 如何在 makefile 中包含和编译库

objective-c - 使用对象容器中的 token 填充 NSTokenField

html - Chrome(Win) 和 Safari (OSX) 对于我的 html 看起来不同

macos - iTerm 2 配置文件

c++ - 如何将 boost::multiprecision::cpp_int 转换为字节数组

c++ - 如何将 Boost.uuid 集成到我的跨平台代码中?

c++ - OpenCV:对 RGB 图像应用操作(拆分+合并)

c++ - 如何将从省略号运算符获得的参数传递给其他函数?

c++ - 如何访问和读取 C++ 文件中的各行?