Installing Google Protocol Buffers on mac

前端 未结 14 1648
轮回少年
轮回少年 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:51
    brew install --devel protobuf
    

    If it tells you "protobuf-2.6.1 already installed": 1. brew uninstall --devel protobuf 2. brew link libtool 3. brew install --devel protobuf

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

    There is another official way by Google, as mentioned by another user.

    Read it fully before trying.

    Here are the steps:

    Open Terminal and type the following

    1. PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
    2. curl -OL https://github.com/google/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
    3. sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
    4. rm -f $PROTOC_ZIP

    Worked for me.

    P.S.
    This is for version 3.7.1 in osx only. If you want to install some other version/platform, visit the releases link and check out the details of the latest version, and use those information. Reference

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

    There are some issues with building protobuf 2.4.1 from source on a Mac. There is a patch that also has to be applied. All this is contained within the homebrew protobuf241 formula, so I would advise using it.

    To install protocol buffer version 2.4.1 type the following into a terminal:

    brew tap homebrew/versions
    brew install protobuf241
    

    If you already have a protocol buffer version that you tried to install from source, you can type the following into a terminal to have the source code overwritten by the homebrew version:

    brew link --force --overwrite protobuf241
    

    Check that you now have the correct version installed by typing:

    protoc --version
    

    It should display 2.4.1

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

    To install Protocol Buffer (as of today version v3.7.0)

    1. Go to this website
    2. download the zip file according to your OS (e.g.: protoc-3.7.0-osx-x86_64.zip). This applies also to other OS.

    3. Move the executable in protoc-3/bin/protoc to one of your directories in PATH. In Mac I suggest to put it into /usr/local/bin

    Now your good to go

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

    It's a new year and there's a new mismatch between the version of protobuf in Homebrew and the cutting edge release. As of February 2016, brew install protobuf will give you version 2.6.1.

    If you want the 3.0 beta release instead, you can install it with:

    brew install --devel protobuf
    
    0 讨论(0)
  • 2020-12-12 11:04

    HomeBrew versions has been removed and formulaes have been emptied. Therefore, my advice is to install it manually following the following steps.

    For the time being you will need to build and install the Protocol Buffers toolset manually.

    1. Download source code: https://github.com/google/protobuf/releases/download/v2.4.1/protobuf-2.4.1.tar.gz

    2. tar xvfz protobuf-2.4.1.tar.gz

    3. cd protobuf-2.4.1

    4. Run ./configure

    5. Edit src/google/protobuf/message.cc, add #include at the top of the file

    6. Run make command from root of the folder, i.e. protobuf-2.4.1/

    7. Run sudo make install

    8. Run /usr/local/bin/protoc --version to check the version of protobuf compiler version The terminal output should be:

      Version: libprotoc 2.4.1

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