Skip to content

Instantly share code, notes, and snippets.

@sofyan-ahmad
Last active February 21, 2023 10:40
Show Gist options
  • Save sofyan-ahmad/37787e5ed098c97919b8c593f0ec44d8 to your computer and use it in GitHub Desktop.
Save sofyan-ahmad/37787e5ed098c97919b8c593f0ec44d8 to your computer and use it in GitHub Desktop.
# Make sure you grab the latest version
curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
# Unzip
unzip protoc-3.2.0-linux-x86_64.zip -d protoc3
# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/
# Move protoc3/include to /usr/local/include/
sudo mv protoc3/include/* /usr/local/include/
# Optional: change owner
sudo chwon [user] /usr/local/bin/protoc
sudo chwon -R [user] /usr/local/include/google
@yurkazaytsev
Copy link

Thanks!

@bedge
Copy link

bedge commented Nov 4, 2017

Latest is now https://github.com/google/protobuf/releases/download/v3.4.0/protoc-3.4.0-linux-x86_64.zip
Also, recommend 'stow' utility for managing non-packaged components.
e.g.:

 %> sudo stow -n cproto -D /usr/local -d /usr/local/stow
Loading defaults from /root/.stowrc
LINK: include/google => ../stow/cproto/include/google
LINK: readme.txt => stow/cproto/readme.txt
LINK: bin/protoc => ../stow/cproto/bin/protoc

Avoids the need to manually copy/link, plus manages what's been added in this manner for later removal/upgrade/etc.

@Arfey
Copy link

Arfey commented Dec 21, 2017

Thx

@aescart1
Copy link

great

@sailfish009
Copy link

thanks for the info!

@sleebapaul
Copy link

it is giving the following error -bash: /usr/local/bin/protoc: cannot execute binary file: Exec format error

@rahuldeo2047
Copy link

Just thought it might be useful to mates, stuck with multiple protobuf versions runtime issue:
protocolbuffers/protobuf#4001

So that we check if there is already a version installed.

@edwardmartinsjr
Copy link

Awesome!

@bigdataplot
Copy link

bigdataplot commented May 3, 2018

Fixed my problem :) Thx

@jeshan
Copy link

jeshan commented May 11, 2018

thanks. consider changing [user] to $USER to make it runnable immediately. also the "chwon" has already been reported above.

@xxlyu-2046
Copy link

should add ln -s /usr/local/bin/protoc /usr/bin/protoc

@deepkshikha
Copy link

Thanks

@purusothaman2502
Copy link

redhat@redhat-HP-245-G5-Notebook-PC:~$ sudo chown [redhat] /usr/local/bin/protocchown: invalid user: ‘[redhat]’
how to solve this error?? ple help me :::))

@sushant1727
Copy link

@purusothaman2502 remove the [ ] for your user.

Command becomes sudo chown redhat /usr/local/bin/protocchown

@janoskut
Copy link

How can I update the library too?
Cmake gives me:
Protobuf compiler version 3.3.0 doesn't match library version 3.0.0
(on ubuntu-bionic)

@Jomes
Copy link

Jomes commented Jul 25, 2018

Thank you!
There are a typos in line 14 and line 15: chown is misspelled.

@shriAG
Copy link

shriAG commented Jul 30, 2018

Hi How to install google protobuf along with protoc ?

@efazati
Copy link

efazati commented Oct 28, 2018

Change chwon to chown

@edxmorgan
Copy link

thanks . workeed

@biswajitAqb
Copy link

Awesome !! Worked.

@pmalhaire
Copy link

I added auto get version and made it work as a script file

#! /bin/bash

TEMP_DIR=/tmp


VERSION=`curl --silent "https://api.github.com/repos/protocolbuffers/protobuf/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")'`

[[ -z VERSION ]] && echo "Could not get version from github"

mkdir $TEMP_DIR/protoc_inst

cd $TEMP_DIR/protoc_inst

# Make sure you grab the latest version
curl -OL "https://github.com/google/protobuf/releases/download/v$VERSION/protoc-$VERSION-linux-x86_64.zip"

# Unzip
unzip "protoc-$VERSION-linux-x86_64.zip" -d protoc3

# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/

# Move protoc3/include to /usr/local/include/
sudo mv protoc3/include/* /usr/local/include/

rm -rf $TEMP_DIR/protoc_inst

@jiankang1991
Copy link

How to solve the problem that is:

Protobuf compiler version 3.6.1 doesn't match library version 3.0.0?

Thank you.

@vboo27
Copy link

vboo27 commented Nov 22, 2018

THX!

@sri-prasanna
Copy link

thanks

@hyperchris
Copy link

Thanks!

@AtsushiSakai
Copy link

Great!! Thanks.

@Albertchieng
Copy link

awesome

@kumarashit
Copy link

Awesome!! Helpful!!

@Albertchieng
Copy link

Albertchieng commented Oct 14, 2019 via email

@gsilano
Copy link

gsilano commented Jan 3, 2020

Here the link to my Gist if you are interested in recovering the previous version of protobuf installed on your pc (Ubuntu 16.04).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment