Development

How to Install the Protocol Buffer Compiler on Mac OS

Captain Salem 1 min read

How to Install the Protocol Buffer Compiler on Mac OS

Protocol Buffers, commonly known as protobufs are a free and open-source cross-platform data format used to serialize structured data. It helps develop programs to communicate with each other over a network or store data. Think of formats such as XML, JSON, Pickle, etc.

Protocol Buffers, however, are much faster and provide a much more compact data storage; they are optimized via automatically generated classes for a wide range of programming languages.

You often encounter protocol buffers when working with tools such as gRPC. They are also used internally by Google cloud and other applications.

Before using protocol buffers on your system, you need to set up the Protocol Buffers compiler or protoc. This tutorial covers the command for installing the Protocol Buffers compiler on mac OS.

Install Protocol Buffer Compiler using Homebrew

As you guessed, we can install the Protocol Buffer compiler using the Homebrew command:

Run:

brew install protobuf

Output:

Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/cask-fonts).
==> New Formulae
mariadb@10.9

You have 12 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

==> Downloading https://ghcr.io/v2/homebrew/core/protobuf/manifests/21.9_1
Already downloaded: /Users/csalem/Library/Caches/Homebrew/downloads/b14adda1b60aed4c5ad02d56334c662c6bf85995bdaa45c069bd7ccf6ef16439--protobuf-21.9_1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/protobuf/blobs/sha256:dcfd589b0
Already downloaded: /Users/csalem/Library/Caches/Homebrew/downloads/e0884d5da59489325249368acbe8cc2b44e442d1cbcd9cd1c0c45649aa97d2cf--protobuf--21.9_1.arm64_ventura.bottle.tar.gz
==> Pouring protobuf--21.9_1.arm64_ventura.bottle.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /opt/homebrew/share/emacs/site-lisp/protobuf
==> Summary
🍺  /opt/homebrew/Cellar/protobuf/21.9_1: 333 files, 20.4MB
==> Running `brew cleanup protobuf`...

Once installed, check the protocol buffer compiler version:

protoc --version

Expected output:

libprotoc 3.19.1

Ensure the installed version is version 3.0+.

End.

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.