Installing Google Protocol Buffers on mac

前端 未结 14 1647
轮回少年
轮回少年 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:41

    For v3 users.

    http://google.github.io/proto-lens/installing-protoc.html

    PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
    curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
    sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
    sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
    rm -f $PROTOC_ZIP
    
    0 讨论(0)
  • 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<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;
    
                               ^

    (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 <istream> 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.

    0 讨论(0)
  • 2020-12-12 10:44

    From https://github.com/paulirish/homebrew-versions-1 . Works for me!

    brew install https://raw.githubusercontent.com/paulirish/homebrew-versions-1/master/protobuf241.rb
    
    0 讨论(0)
  • 2020-12-12 10:45

    This is not via brew, but the end result is the same.

    1. Download the protobuf-2.4.1 from https://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
    2. Extract the tar.gz file.
    3. $cd ~/Downloads/protobuf-2.4.1
    4. $./configure
    5. $make
    6. $make check
    7. $sudo make install
    8. $which protoc
    9. $protoc --version

    Steps 4-7 are from the README.txt file from the protobuf tarball.

    0 讨论(0)
  • 2020-12-12 10:49

    you can install from official link page provided by google http://google.github.io/proto-lens/installing-protoc.html

    0 讨论(0)
  • 2020-12-12 10:50

    If you landed here looking for how to install Protocol Buffers on Mac, it can be done using Homebrew by running the command below

    brew install protobuf
    

    It installs the latest version of protobuf available. For me, at the time of writing, this installed the v3.7.1

    If you'd like to install an older version, please look up the available ones from the package page Protobuf Package - Homebrew and install that specific version of the package.

    The oldest available protobuf version in this package is v3.6.1.3

    0 讨论(0)
提交回复
热议问题