Search code examples
gccosx-mavericksmesos

How do you fix "implicit instantiation" errors when compiling Mesos on OS X 10.9 Mavericks?


After upgrading to OS X Mavericks, running make in my Mesos build directory results in errors:

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;

I started with a clean build directory, re-ran ./bootstrap, and ran cd build && ../configure.


Solution

  • OS X Mavericks replaced the gcc command with clang:

    $ gcc
    clang: error: no input files
    

    However, Mesos currently expects to be compiled with the GNU Compiler Collection. You need to install GCC 4.7 with Homebrew and configure your build directory to use it. To be sure, start with an empty build directory:

    # 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
    

    Then you can run make like before.