How can I install protoc, the protobuf compiler to generate Java, on Ubuntu 16.04?
Here is Solutions:
We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.
$ sudo apt-get install autoconf automake libtool curl make g++ unzip
- From this page, download the
- Extract the contents and change in the directory
sudo make install
sudo ldconfig # refresh shared library cache.
Check if it works
$ protoc --version libprotoc 3.6.1
sudo apt install protobuf-compiler
If you are a non-C++ user and/or don’t want to compile it yourself, the simplest way to install the current version of protoc is to download a pre-built binary from the release page.
To install, simply place this binary somewhere in your PATH (e.g. /usr/local/bin).
(If you intend to use the included well known types then don’t forget to
copy the contents of the ‘include’ directory somewhere as well, for example
You can download binary from the source code and use next commands
sudo rm -rf ./protoc unzip protoc-3.10.1-linux-x86_64.zip -d protoc chmod 755 -R protoc BASE=/usr/local sudo rm -rf $BASE/include/google/protobuf/ sudo cp protoc/bin/protoc $BASE/bin sudo cp -R protoc/include/* $BASE/include
Change your base to /usr/, or /usr/loca/, or anything else in your PATH.
1) Download binary from the url https://github.com/protocolbuffers/protobuf/releases
2) extract and keep the directory at particular location (/user/app/protoc)
3) add the entry in /usr//.bash_profile as
4) refresh file
Other option is run the following command one by one after downloading the repository :
sudo rm -rf ./protoc
unzip protoc-3.10.1-linux-x86_64.zip -d protoc
chmod 755 -R protoc
sudo rm -rf $BASE/include/google/protobuf/
sudo cp protoc/bin/protoc $BASE/bin
sudo cp -R protoc/include/* $BASE/include
Use this if you are having errors like
google/protobuf/descriptor.proto: File not found.
google/protobuf/duration.proto: File not found.
google/protobuf/timestamp.proto: File not found.
PROTOC_ZIP=protoc-3.7.1-linux-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
This is useful when you are doing generation for go using protoc-gen-go as it requires the base proto files to be present in default include folders
Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂