- Protocol Buffer Compiler Installation
- Protocol Buffer Compiler Installation
- Install using a package manager
- Warning
- Install pre-compiled binaries (any OS)
- Other installation options
- Protoc mac os install
- Protoc mac os install
- About
- rajkrrsingh / Google protobuf installation on Mac
- This comment has been minimized.
- okulkarni-weekendr commented Apr 9, 2018
- This comment has been minimized.
- Zhenye-Na commented Sep 16, 2018
- This comment has been minimized.
- yunfan123 commented Sep 27, 2018
- This comment has been minimized.
- Ragnyll commented Mar 5, 2019
- This comment has been minimized.
- akiasprin commented Mar 8, 2019
- This comment has been minimized.
- guoshuai commented Mar 30, 2019
- This comment has been minimized.
- sriki77 commented Jun 30, 2019
- This comment has been minimized.
- haiboself commented Sep 1, 2019
- This comment has been minimized.
- plainbanana commented Sep 10, 2019
- This comment has been minimized.
- snemuri commented Oct 15, 2019
- This comment has been minimized.
- djcvijic commented Nov 14, 2019
- This comment has been minimized.
- adigunhammedolalekan commented Nov 14, 2019
- This comment has been minimized.
- weina2018 commented Nov 23, 2019
- This comment has been minimized.
- weina2018 commented Nov 23, 2019
- This comment has been minimized.
- StanSun commented Dec 1, 2019
- This comment has been minimized.
- datng2 commented Dec 6, 2019
- This comment has been minimized.
- chaoman commented Feb 25, 2020
- This comment has been minimized.
- Stephan14 commented Mar 1, 2020
- This comment has been minimized.
- SamsonLai commented Mar 25, 2020
- This comment has been minimized.
- deximat commented Jun 1, 2020
- This comment has been minimized.
- bhupathiv commented Oct 19, 2020
- This comment has been minimized.
- ijulanday commented Nov 24, 2020
- This comment has been minimized.
- vineetgarg02 commented Feb 11, 2021
- This comment has been minimized.
- guanjinke commented Mar 16, 2021
- This comment has been minimized.
- april1989 commented Mar 18, 2021
- This comment has been minimized.
- tj-byun commented May 7, 2021
- This comment has been minimized.
- dzypersonal commented May 27, 2021
- This comment has been minimized.
- tianhong-1 commented Jul 27, 2021 •
- This comment has been minimized.
- tianhong-1 commented Jul 27, 2021
- This comment has been minimized.
- tianhong-1 commented Jul 27, 2021
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 .
Источник
Protoc mac os install
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:
Источник
Protoc mac os install
Protocol Buffers — Google’s data interchange format
Copyright 2008 Google Inc.
Protocol Buffers (a.k.a., protobuf) are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data. You can find protobuf’s documentation on the Google Developers site.
This README file contains protobuf installation instructions. To install protobuf, you need to install the protocol compiler (used to compile .proto files) and the protobuf runtime for your chosen programming language.
Protocol Compiler Installation
The protocol compiler is written in C++. If you are using C++, please follow the C++ Installation Instructions to install protoc along with the C++ runtime.
For non-C++ users, the simplest way to install the protocol compiler is to download a pre-built binary from our release page:
In the downloads section of each release, you can find pre-built binaries in zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary as well as a set of standard .proto files distributed along with protobuf.
If you are looking for an old version that is not available in the release page, check out the maven repo here:
These pre-built binaries are only provided for released versions. If you want to use the github master version at HEAD, or you need to modify protobuf code, or you are using C++, it’s recommended to build your own protoc binary from source.
If you would like to build protoc binary from source, see the C++ Installation Instructions.
Protobuf Runtime Installation
Protobuf supports several different programming languages. For each programming language, you can find instructions in the corresponding source directory about how to install protobuf runtime for that specific language:
Language | Source |
---|---|
C++ (include C++ runtime and protoc) | src |
Java | java |
Python | python |
Objective-C | objectivec |
C# | csharp |
JavaScript | js |
Ruby | ruby |
Go | protocolbuffers/protobuf-go |
PHP | php |
Dart | dart-lang/protobuf |
The best way to learn how to use protobuf is to follow the tutorials in our developer guide:
If you want to learn from code examples, take a look at the examples in the examples directory.
The complete documentation for Protocol Buffers is available via the web at:
About
Protocol Buffers — Google’s data interchange format
Источник
rajkrrsingh / Google protobuf installation on Mac
$wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2 |
$tar xvf protobuf-2.5.0.tar.bz2 |
$cd protobuf-2.5.0 |
$./configure CC=clang CXX=clang++ CXXFLAGS=’-std=c++11 -stdlib=libc++ -O3 -g’ LDFLAGS=’-stdlib=libc++’ LIBS=»-lc++ -lc++abi» |
$make -j 4 |
$sudo make install |
$protoc —version |
This comment has been minimized.
Copy link Quote reply
okulkarni-weekendr commented Apr 9, 2018
Thanks a lot.. saved 2 hours..
This comment has been minimized.
Copy link Quote reply
Zhenye-Na commented Sep 16, 2018
Thanks sooo much!
This comment has been minimized.
Copy link Quote reply
yunfan123 commented Sep 27, 2018
This comment has been minimized.
Copy link Quote reply
Ragnyll commented Mar 5, 2019
This comment has been minimized.
Copy link Quote reply
akiasprin commented Mar 8, 2019
try it: brew install protobuf@2.5 🙂
This comment has been minimized.
Copy link Quote reply
guoshuai commented Mar 30, 2019
It won’t work unfortunately because protobuf@2.5 formula has been deprecated.
This comment has been minimized.
Copy link Quote reply
sriki77 commented Jun 30, 2019
thank you very much. big time saver
This comment has been minimized.
Copy link Quote reply
haiboself commented Sep 1, 2019
This comment has been minimized.
Copy link Quote reply
plainbanana commented Sep 10, 2019
thanks. it still works at Mojave.
This comment has been minimized.
Copy link Quote reply
snemuri commented Oct 15, 2019
This comment has been minimized.
Copy link Quote reply
djcvijic commented Nov 14, 2019
This comment has been minimized.
Copy link Quote reply
adigunhammedolalekan commented Nov 14, 2019
Try brew install protobuf
This comment has been minimized.
Copy link Quote reply
weina2018 commented Nov 23, 2019
Hi there, anyone could help to have the new version of «https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2» as it appears too old to install protobuf on macOS now thank you in advance, Edina
This comment has been minimized.
Copy link Quote reply
weina2018 commented Nov 23, 2019
I tried brew install protobuf, then brew link —overwrite protobuf it works on Macos with protobuf /3.10.1
This comment has been minimized.
Copy link Quote reply
StanSun commented Dec 1, 2019
brew install protobuf
➜
protoc —version
libprotoc 3.11.0
This comment has been minimized.
Copy link Quote reply
datng2 commented Dec 6, 2019
For those who running on Mac OS Mojave 10.14 ran into error while running this line:
The fix is to install macOS_SDK_headers_for_macOS
This comment has been minimized.
Copy link Quote reply
chaoman commented Feb 25, 2020
Thanks so much. Got it working.
This comment has been minimized.
Copy link Quote reply
Stephan14 commented Mar 1, 2020
This comment has been minimized.
Copy link Quote reply
SamsonLai commented Mar 25, 2020
It works on my Mac, Thanks a lot!
This comment has been minimized.
Copy link Quote reply
deximat commented Jun 1, 2020
This comment has been minimized.
Copy link Quote reply
bhupathiv commented Oct 19, 2020
It works perfectly on my Mac. Thanks you very much..
This comment has been minimized.
Copy link Quote reply
ijulanday commented Nov 24, 2020
Needed to install protobuf 3.13.0 with 3.14.0 currently installed on Catalina 10.15.7–worked perfectly!
This comment has been minimized.
Copy link Quote reply
vineetgarg02 commented Feb 11, 2021
Anyone got this working on Apple silicon?
This comment has been minimized.
Copy link Quote reply
guanjinke commented Mar 16, 2021
This comment has been minimized.
Copy link Quote reply
april1989 commented Mar 18, 2021
This comment has been minimized.
Copy link Quote reply
tj-byun commented May 7, 2021
This comment has been minimized.
Copy link Quote reply
dzypersonal commented May 27, 2021
Failed on mac big sur, exception like this:
./google/protobuf/stubs/atomicops_internals_macosx.h:158:43: error: unknown type name ‘Atomic64’; did you mean ‘Atomic32’?
Atomic64 increment) <
^
Atomic32
Does anyone have an idea?
This comment has been minimized.
Copy link Quote reply
tianhong-1 commented Jul 27, 2021 •
Anyone got this working on Apple silicon?
This comment has been minimized.
Copy link Quote reply
tianhong-1 commented Jul 27, 2021
Failed on mac big sur, exception like this:
./google/protobuf/stubs/atomicops_internals_macosx.h:158:43: error: unknown type name ‘Atomic64’; did you mean ‘Atomic32’?
Atomic64 increment) <
^
Atomic32
Does anyone have an idea?
This comment has been minimized.
Copy link Quote reply
tianhong-1 commented Jul 27, 2021
Failed on mac big sur, exception like this:
./google/protobuf/stubs/atomicops_internals_macosx.h:158:43: error: unknown type name ‘Atomic64’; did you mean ‘Atomic32’?
Atomic64 increment) <
^
Atomic32
Does anyone have an idea?
Источник