Installing Google Protocol Buffers on mac

前端 未结 14 1757
轮回少年
轮回少年 2020-12-12 10:24

I would like to install the older version of Google Protocol Buffers (protobuf-2.4.1) on mac using Terminal command line. I tried with brew install protobuf, bu

14条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 10:43

    For some reason I need to use protobuf 2.4.1 in my project on OS X El Capitan. However homebrew has removed protobuf241 from its formula. I install it according @kksensei's answer manually and have to fix some error during the process.

    During the make process, I get 3 error like following:

    google/protobuf/message.cc:130:60: error: implicit instantiation of undefined template 'std::__1::basic_istream >'
    
      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 >'
    
      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 >'
    
      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;
    
                               ^

    (Sorry, I dont know how to attach code when the code contains '`' )

    If you get the same error, please edit src/google/protobuf/message.cc, add #include at the top of the file and do $ make again and should get no errors. After that do $ sudo make install. When install finished $protoc --version should display the correct result.

提交回复
热议问题