在OS X 10.9 Mavericks上编译Mesos时,如何修复“隐式实例化”错误?

时间:2013-11-01 02:01:58

标签: gcc osx-mavericks mesos

升级到OS X Mavericks后,在我的Mesos构建目录中运行make会导致错误:

google/protobuf/message.cc:130:60: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >'
  return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
                                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here
    class _LIBCPP_TYPE_VIS basic_istream;
                           ^
google/protobuf/message.cc:135:67: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >'
  return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
                                                                  ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here
    class _LIBCPP_TYPE_VIS basic_istream;
                           ^
google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
  return output->good();
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:110:28: note: template is declared here
    class _LIBCPP_TYPE_VIS basic_ostream;

我从干净的构建目录开始,重新运行./bootstrap,然后运行cd build && ../configure

2 个答案:

答案 0 :(得分:16)

对于那些在Googling错误消息中找到此页面的人,这些错误消息是由某些其他依赖旧版Google protobuf库的软件引发的,这是另一种解决方案:

修改文件src/google/protobuf/message.cc并在开始注释块之后添加行#include <iostream>,就在所有其余#include行之前。这个单行更改足以使我能够使用El Capitan Mac上的XCode 7.3中的命令行工具从protoc编译protobuf-2.4.1

答案 1 :(得分:9)

OS X Mavericks将gcc命令替换为clang

$ gcc
clang: error: no input files

但是,Mesos目前希望使用GNU Compiler Collection进行编译。您需要使用Homebrew安装GCC 4.7并配置您的构建目录以使用它。可以肯定的是,从一个空的构建目录开始:

# Install GCC 4.7
brew tap homebrew/versions
brew install gcc47

# Configure Mesos build to use GCC
cd /path/to/mesos
rm -rf build
mkdir build
cd build
CC=gcc-4.7 CXX=g++-4.7 ../configure

然后你可以像以前一样运行make