- Protocol Buffer Compiler Installation
- Protocol Buffer Compiler Installation
- Install using a package manager
- Warning
- Install pre-compiled binaries (any OS)
- Other installation options
- How to install protobuf linux
- diegopacheco / latest-protobuf-ubuntu-18-04.md
- This comment has been minimized.
- lehainam-dev commented Jul 30, 2018
- This comment has been minimized.
- seantcanavan commented Dec 10, 2018
- This comment has been minimized.
- SamRicha commented Feb 28, 2019
- This comment has been minimized.
- trung1309vn commented Aug 9, 2019
- This comment has been minimized.
- i-amgeek commented Aug 10, 2019
- This comment has been minimized.
- apepkuss commented Oct 17, 2019
- This comment has been minimized.
- celdeldel commented Oct 26, 2019
- This comment has been minimized.
- ravisrhyme commented Oct 29, 2019
- This comment has been minimized.
- Xunino commented Nov 14, 2019
- This comment has been minimized.
- fospathi commented Dec 17, 2019
- This comment has been minimized.
- kramer65 commented Feb 25, 2020
- ryujaehun / Install protobuf 3.6.1 on Ubuntu 16.04
- This comment has been minimized.
- martinthurn commented Nov 7, 2018 •
- This comment has been minimized.
- jpedroes commented Mar 7, 2019
- This comment has been minimized.
- thavoo commented Jun 18, 2019
- This comment has been minimized.
- jhonnynetworker commented Jun 19, 2019
- This comment has been minimized.
- alsundma commented Jun 21, 2019
- This comment has been minimized.
- KrishnaGolakoti commented Jul 24, 2019
- This comment has been minimized.
- suraj2596 commented Nov 29, 2019 •
- This comment has been minimized.
- etatbak commented Feb 14, 2020
- This comment has been minimized.
- chienkan commented Mar 3, 2020
- This comment has been minimized.
- chandiprasad commented Sep 13, 2020
- olivoil / Install protobuf 3.5 on Ubuntu 18.04
- This comment has been minimized.
- rustyhamsterr commented May 13, 2018
- This comment has been minimized.
- rgov commented Feb 14, 2019
- This comment has been minimized.
- ZAFERSHAMIM commented Feb 22, 2019
- This comment has been minimized.
- MeirionHughes commented Mar 1, 2019
- This comment has been minimized.
- cboulay commented Mar 6, 2019
- This comment has been minimized.
- liangdzou commented May 6, 2019
- This comment has been minimized.
- machmum commented May 9, 2019 •
Protocol Buffer Compiler Installation
How to install the protocol buffer compiler.
Protocol Buffer Compiler Installation
While not mandatory, gRPC applications often leverage Protocol Buffers for service definitions and data serialization. Most of the example code from this site uses version 3 of the protocol buffer language (proto3) .
The protocol buffer compiler, protoc , is used to compile .proto files, which contain service and message definitions. Choose one of the methods given below to install protoc .
Install using a package manager
You can install the protocol compiler, protoc , with a package manager under Linux or macOS using the following commands.
Warning
Check the version of protoc (as indicated below) after installation to ensure that it is sufficiently recent. The versions of protoc installed by some package managers can be quite dated.
Installing from pre-compiled binaries, as indicated in the next section, is the best way to ensure that you’re using the latest release of protoc .
Linux, using apt or apt-get , for example:
Install pre-compiled binaries (any OS)
To install the latest release of the protocol compiler from pre-compiled binaries, follow these instructions:
Manually download from github.com/google/protobuf/releases the zip file corresponding to your operating system and computer architecture ( protoc- — .zip ), or fetch the file using commands such as the following:
Unzip the file under $HOME/.local or a directory of your choice. For example:
Update your environment’s path variable to include the path to the protoc executable. For example:
Other installation options
If you’d like to build the protocol compiler from sources, or access older versions of the pre-compiled binaries, see Download Protocol Buffers .
Источник
How to install protobuf linux
Copy raw contents
Protocol Buffers — Google’s data interchange format
Copyright 2008 Google Inc.
C++ Installation — Unix
To build protobuf from source, the following tools are needed:
On Ubuntu/Debian, you can install them with:
On other platforms, please use the corresponding package managing tool to install them before proceeding.
To get the source, download one of the release .tar.gz or .zip packages in the release page:
For example: if you only need C++, download protobuf-cpp-[VERSION].tar.gz ; if you need C++ and Java, download protobuf-java-[VERSION].tar.gz (every package contains C++ source already); if you need C++ and multiple other languages, download protobuf-all-[VERSION].tar.gz .
You can also get the source by «git clone» our git repository. Make sure you have also cloned the submodules and generated the configure script (skip this if you are using a release .tar.gz or .zip package):
To build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc) execute the following:
If «make check» fails, you can still install, but it is likely that some features of this library will not work correctly on your system. Proceed at your own risk.
For advanced usage information on configure and make, please refer to the autoconf documentation:
Hint on install location
By default, the package will be installed to /usr/local. However, on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. You can add it, but it may be easier to just install to /usr instead. To do this, invoke configure as follows:
If you already built the package with a different prefix, make sure to run «make clean» before building again.
Compiling dependent packages
To compile a package that uses Protocol Buffers, you need to pass various flags to your compiler and linker. As of version 2.2.0, Protocol Buffers integrates with pkg-config to manage this. If you have pkg-config installed, then you can invoke it to get a list of flags like so:
Note that packages written prior to the 2.2.0 release of Protocol Buffers may not yet integrate with pkg-config to get flags, and may not pass the correct set of flags to correctly link against libprotobuf. If the package in question uses autoconf, you can often fix the problem by invoking its configure script like:
This will force it to use the correct flags.
If you are writing an autoconf-based package that uses Protocol Buffers, you should probably use the PKG_CHECK_MODULES macro in your configure script like:
See the pkg-config man page for more info.
If you only want protobuf-lite, substitute «protobuf-lite» in place of «protobuf» in these examples.
Note for Mac users
For a Mac system, Unix tools are not available by default. You will first need to install Xcode from the Mac AppStore and then run the following command from a terminal:
To install Unix tools, you can install «port» following the instructions at https://www.macports.org . This will reside in /opt/local/bin/port for most Mac installations.
Then follow the Unix instructions above.
Note for cross-compiling
The makefiles normally invoke the protoc executable that they just built in order to build tests. When cross-compiling, the protoc executable may not be executable on the host machine. In this case, you must build a copy of protoc for the host machine first, then use the —with-protoc option to tell configure to use it instead. For example:
This will use the installed protoc (found in your $PATH) instead of trying to execute the one built during the build process. You can also use an executable that hasn’t been installed. For example, if you built the protobuf package for your host machine in ../host, you might do:
Either way, you must make sure that the protoc executable you use has the same version as the protobuf source code you are trying to use it with.
Note for Solaris users
Solaris 10 x86 has a bug that will make linking fail, complaining about libstdc++.la being invalid. We have included a work-around in this package. To use the work-around, run configure as follows:
See src/solaris/libstdc++.la for more info on this bug.
Note for HP C++ Tru64 users
To compile invoke configure as follows:
Also, you will need to use gmake instead of make.
Note for AIX users
Compile using the IBM xlC C++ compiler as follows:
Also, you will need to use GNU make ( gmake ) instead of AIX make .
C++ Installation — Windows
If you only need the protoc binary, you can download it from the release page:
In the downloads section, download the zip file protoc-$VERSION-win32.zip. It contains the protoc binary as well as public proto files of protobuf library.
Protobuf and its dependencies can be installed directly by using vcpkg :
If zlib support is desired, you’ll also need to install the zlib feature:
To build from source using Microsoft Visual C++, see cmake/README.md.
To build from source using Cygwin or MinGW, follow the Unix installation instructions, above.
Binary Compatibility Warning
Due to the nature of C++, it is unlikely that any two versions of the Protocol Buffers C++ runtime libraries will have compatible ABIs. That is, if you linked an executable against an older version of libprotobuf, it is unlikely to work with a newer version without re-compiling. This problem, when it occurs, will normally be detected immediately on startup of your app. Still, you may want to consider using static linkage. You can configure this package to install static libraries only using:
The complete documentation for Protocol Buffers is available via the web at:
Источник
diegopacheco / latest-protobuf-ubuntu-18-04.md
This comment has been minimized.
Copy link Quote reply
lehainam-dev commented Jul 30, 2018
You’re missing ./configure after ./autogen.sh .
This comment has been minimized.
Copy link Quote reply
seantcanavan commented Dec 10, 2018
This is great thank you
This comment has been minimized.
Copy link Quote reply
SamRicha commented Feb 28, 2019
This comment has been minimized.
Copy link Quote reply
trung1309vn commented Aug 9, 2019
This comment has been minimized.
Copy link Quote reply
i-amgeek commented Aug 10, 2019
This comment has been minimized.
Copy link Quote reply
apepkuss commented Oct 17, 2019
This comment has been minimized.
Copy link Quote reply
celdeldel commented Oct 26, 2019
This comment has been minimized.
Copy link Quote reply
ravisrhyme commented Oct 29, 2019
I am trying to install protobuf in my ubuntu ec2 instance.
I followed above steps and tried compiling my .proto file with —python_out.
If it try to import generated python module, I am getting following error:
ModuleNotFoundError: No module named ‘google’
Did someone see this kind of error before ? any idea how I can resolve this ?
This comment has been minimized.
Copy link Quote reply
Xunino commented Nov 14, 2019
This comment has been minimized.
Copy link Quote reply
fospathi commented Dec 17, 2019
Official UNIX install instructions are here: README.md.
This comment has been minimized.
Copy link Quote reply
kramer65 commented Feb 25, 2020
I am trying to install protobuf in my ubuntu ec2 instance.
I followed above steps and tried compiling my .proto file with —python_out.
If it try to import generated python module, I am getting following error:
ModuleNotFoundError: No module named ‘google’
Did someone see this kind of error before ? any idea how I can resolve this ?
You also need the Python bindings. To install them simply do
Источник
ryujaehun / Install protobuf 3.6.1 on Ubuntu 16.04
#! /bin/bash |
# Make sure you grab the latest version |
curl -OL https://github.com/google/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip |
https://github.com/google/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip |
# Unzip |
unzip protoc-3.6.1-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 chown $USER /usr/local/bin/protoc |
sudo chown -R $USER /usr/local/include/google |
This comment has been minimized.
Copy link Quote reply
martinthurn commented Nov 7, 2018 •
Thank you for this!
Rather than mv, I prefer cp -pr
Also, one should also do sudo ldconfig at the end, to add the new libraries to the LD path
This comment has been minimized.
Copy link Quote reply
jpedroes commented Mar 7, 2019
This comment has been minimized.
Copy link Quote reply
thavoo commented Jun 18, 2019
thanks for this.
This comment has been minimized.
Copy link Quote reply
jhonnynetworker commented Jun 19, 2019
This comment has been minimized.
Copy link Quote reply
alsundma commented Jun 21, 2019
Thank! very helpful.
This comment has been minimized.
Copy link Quote reply
KrishnaGolakoti commented Jul 24, 2019
I have followed the above steps to upgrade from older version of protoc to 3+. still I get protoc —version as «libprotoc 2.6.1».
This comment has been minimized.
Copy link Quote reply
suraj2596 commented Nov 29, 2019 •
This comment has been minimized.
Copy link Quote reply
etatbak commented Feb 14, 2020
This comment has been minimized.
Copy link Quote reply
chienkan commented Mar 3, 2020
I have followed the above steps to upgrade from older version of protoc to 3+. still I get protoc —version as «libprotoc 2.6.1».
I have the same problem, how did you solved this?
This comment has been minimized.
Copy link Quote reply
chandiprasad commented Sep 13, 2020
Thanks !! That works like a charm !
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
olivoil / Install protobuf 3.5 on Ubuntu 18.04
# Make sure you grab the latest version |
curl -OL https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip |
# Unzip |
unzip protoc-3.5.1-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 chown $USER /usr/local/bin/protoc |
sudo chown -R $USER /usr/local/include/google |
This comment has been minimized.
Copy link Quote reply
rustyhamsterr commented May 13, 2018
This comment has been minimized.
Copy link Quote reply
rgov commented Feb 14, 2019
Note that this only installs the Protobuf compiler, and not the runtime library.
This comment has been minimized.
Copy link Quote reply
ZAFERSHAMIM commented Feb 22, 2019
I want to compile Protoc for object detection api of Tensorflow will it work for that too, i am using ubuntu 18.04
This comment has been minimized.
Copy link Quote reply
MeirionHughes commented Mar 1, 2019
you might need to install a dep too:
This comment has been minimized.
Copy link Quote reply
cboulay commented Mar 6, 2019
I was able to get what I needed with sudo apt-get install libprotobuf-dev protobuf-compiler
This comment has been minimized.
Copy link Quote reply
liangdzou commented May 6, 2019
@cboulay apt install gets 3.0
This comment has been minimized.
Copy link Quote reply
machmum commented May 9, 2019 •
I’m using Ubuntu 18.04, install protoc using this, and when I tried to compile my .proto file it said
protoc-gen-go: program not found or is not executable
—go_out: protoc-gen-go: Plugin failed with status code 1.
while run protoc-gen-go tell me
zsh: command not found: protoc-gen-go
Источник