Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
@dminGod

This comment has been minimized.

dminGod commented May 1, 2017

Awesome! : )

@afcastano

This comment has been minimized.

afcastano commented May 17, 2017

The problem with the last step is that the types like Timestamp are not loaded.
I did change the last step to:
ln -s /protoc3/bin/protoc /usr/bin/protoc

That fixed the problem!

@mathben

This comment has been minimized.

mathben commented May 25, 2017

@steven-ferrer

This comment has been minimized.

steven-ferrer commented May 29, 2017

@afcastano, that means I still need to maintain the protoc3/bin/protoc file right? since deleting It would cause problems

@alecholmez

This comment has been minimized.

alecholmez commented Jun 12, 2017

Wait.. you can't symlink it if an earlier version of protoc exist.

@charan223

This comment has been minimized.

charan223 commented Jun 21, 2017

you are awesome

@fisheess

This comment has been minimized.

fisheess commented Jun 23, 2017

best solution on github!

@fractalDimension

This comment has been minimized.

fractalDimension commented Jul 10, 2017

Thank you!

@imbur

This comment has been minimized.

imbur commented Aug 13, 2017

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

@jtavara23

This comment has been minimized.

jtavara23 commented Aug 23, 2017

great!

@vCloudernBeer

This comment has been minimized.

vCloudernBeer commented Sep 6, 2017

@afcastano which step you are referring to as the last step is changed to "ln -s /protoc3/bin/protoc /usr/bin/protoc". Seems like the last step is "sudo mv protoc3/include/* /usr/local/include/". Or you are adding this as the last step?

I followed the steps and did not encounter any problem. thanks for the information. :)

@rvegas

This comment has been minimized.

rvegas commented Sep 19, 2017

@sofyanhadia You have a typo on:

# Optional: change owner
sudo chwon [user] /usr/local/bin/protoc
sudo chwon -R [user] /usr/local/include/google

Change chwon to chown 😏

@yurkazaytsev

This comment has been minimized.

yurkazaytsev commented Oct 18, 2017

Thanks!

@bedge

This comment has been minimized.

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

This comment has been minimized.

Arfey commented Dec 21, 2017

Thx

@aescart1

This comment has been minimized.

aescart1 commented Dec 30, 2017

great

@sailfish009

This comment has been minimized.

sailfish009 commented Jan 20, 2018

thanks for the info!

@sleebapaul

This comment has been minimized.

sleebapaul commented Mar 22, 2018

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

@rahuldeo2047

This comment has been minimized.

rahuldeo2047 commented Apr 12, 2018

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

This comment has been minimized.

edwardmartinsjr commented Apr 30, 2018

Awesome!

@bigdataplot

This comment has been minimized.

bigdataplot commented May 3, 2018

Fixed my problem :) Thx

@jeshan

This comment has been minimized.

jeshan commented May 11, 2018

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

@xiadeye

This comment has been minimized.

xiadeye commented May 29, 2018

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

@deepkshikha

This comment has been minimized.

deepkshikha commented Jul 12, 2018

Thanks

@purusothaman2502

This comment has been minimized.

purusothaman2502 commented Jul 15, 2018

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

This comment has been minimized.

sushant1727 commented Jul 19, 2018

@purusothaman2502 remove the [ ] for your user.

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

@noshky

This comment has been minimized.

noshky commented Jul 20, 2018

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

This comment has been minimized.

Jomes commented Jul 25, 2018

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

@shriAG

This comment has been minimized.

shriAG commented Jul 30, 2018

Hi How to install google protobuf along with protoc ?

@efazati

This comment has been minimized.

efazati commented Oct 28, 2018

Change chwon to chown

@Eddy-Morgan

This comment has been minimized.

Eddy-Morgan commented Nov 9, 2018

thanks . workeed

@biswajitAqb

This comment has been minimized.

biswajitAqb commented Nov 12, 2018

Awesome !! Worked.

@pmalhaire

This comment has been minimized.

pmalhaire commented Nov 15, 2018

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
@karlTUM

This comment has been minimized.

karlTUM commented Nov 15, 2018

How to solve the problem that is:

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

Thank you.

@vboo27

This comment has been minimized.

vboo27 commented Nov 22, 2018

THX!

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