Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Google Protocol Buffers on mac

I would like to install the older version of Google Protocol Buffers (protobuf-2.4.1) on Mac using the command line/Terminal app.

I tried with brew install protobuf, but the latest version 2.5.0 has been installed.

Is it possible to install the older version from the terminal?

like image 693
informatiker Avatar asked Feb 14 '14 09:02

informatiker


People also ask

How do I update Google protobuf?

After you moved protoc file to /usr/local/bin check its permissions as simple as ls -la /usr/local/bin and look for that protoc file. Probably you want to do sudo chown root:root /usr/local/bin/protoc . UPDATE: Same applies to /usr/local/include/google/protobuf/* if you are using gRPC.

What is Google protocol buffer used for?

What are protocol buffers? Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.

What does protoc command do?

protoc is a compiler for protocol buffers definitions files. It can can generate C++, Java and Python source code for the classes defined in PROTO_FILE.


2 Answers

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

like image 180
John Gilmore Avatar answered Oct 18 '22 01:10

John Gilmore


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

  1. Download the protobuf-2.4.1 from https://github.com/protocolbuffers/protobuf/releases/tag/v2.4.1
  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.

like image 26
kksensei Avatar answered Oct 18 '22 02:10

kksensei