Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protoc: command not found (Linux)

I am trying to use Protobuf on Linux box. I downloaded the pre-compiled from github.

When I try to compile my .proto file or just check the protobuf version, it says

protoc: command not found.

I tried the same steps on Windows machine using pre-compiled protobuf version and it works fine there.

like image 300
sgmbd Avatar asked Dec 07 '17 22:12

sgmbd


People also ask

What is protoc command?

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.

What is a protoc plugin?

A protoc plugin is a program that gets invoked by protoc (the protobuf compiler) and generates output files based on a set of input protocol buffers. The plugins are programs that read a CodeGeneratorRequest via their standard input and write a CodeGeneratorResponse to their standard output.


2 Answers

Install protoc for Linux and Mac

Linux

PROTOC_ZIP=protoc-3.15.8-linux-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.15.8/$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

Mac OS X

brew install protobuf

Alternately, if you don't have Homebrew.

PROTOC_ZIP=protoc-3.15.8-osx-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.15.8/$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

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

like image 57
Amit Avatar answered Sep 21 '22 06:09

Amit


For Linux Ubuntu 20, only install with snap

snap install protobuf --classic

or via apt, with:

sudo apt install protobuf-compiler
like image 35
GiovannyLucas Avatar answered Sep 21 '22 06:09

GiovannyLucas