protobuf
protobuf copied to clipboard
Documentation is missing build/linking instructions
What version of protobuf and what language are you using?
Version:
protoc --version
libprotoc 3.21.8
Language: C++
What operating system (Linux, Windows, ...) and version?
Mac OS 12.6 / Apple Silicon ARM64
uname -srm
Darwin 21.6.0 arm64
What runtime / compiler are you using (e.g., python version or gcc version)
g++ --version
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
What did you do?
Read the manual
Steps to reproduce the behavior:
- Install via homebrew
brew install protobuf
What did you expect to see
Instructions on how to compile code sample and link against libraries.
What did you see instead?
Absolutely no build instructions.
Could not find any details on compiling in any of the github readmes or any of the online C++ docs.
What else did you try?
- Searching Google on "how to build protobuf"
- Guessing random build configurations:
llvm-g++ main.cc
In file included from main.cc:4:
./addressbook.pb.h:10:10: fatal error: 'google/protobuf/port_def.inc' file not found
#include <google/protobuf/port_def.inc>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
g++ -L/opt/homebrew/lib -lprotobuf main.cc
In file included from main.cc:4:
./addressbook.pb.h:10:10: fatal error: 'google/protobuf/port_def.inc' file not found
#include <google/protobuf/port_def.inc>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Was able to figure it out on my own, after running into several other issues (like c++11 requirements)
g++ -I/opt/homebrew/include -L/opt/homebrew/lib -lprotobuf -std=c++11 main.cc addressbook.pb.cc -o addressbook
I still think it would be worth mentioning in the actual documentation, however.
I'm glad you were able to figure it out!
I agree it is worth documenting, and this is something we have plans for but haven't had time to prioritize. Any contributions to the docs with what you learned would be greatly appreciated!
brew installs libprotoc 3.19.1
and not the latest version. Any fix for this?
Already tried brew upgrade protobuf
, it warns me that the latest is already installed
The protobuf team does not maintain installation through homebrew. My understanding is that is maintained by homebrew directly, so I would reach out to them.
I was able to build pycld3 which is based on libprotoc on M1 MacBook Air by installing latest protobuf 21.12 and running
export LDFLAGS=-L/opt/homebrew/lib
export CPPFLAGS=-I/opt/homebrew/include
I was able to build pycld3 which is based on libprotoc on M1 MacBook Air by installing latest protobuf 21.12 and running
export LDFLAGS=-L/opt/homebrew/lib export CPPFLAGS=-I/opt/homebrew/include
Thank you very much for that solution it worked on my M1 MacBook Pro also 👍 I've stumbled upon some other solution if that doesn't work for you maybe the other does.(https://github.com/google/cld3/issues/80)
pip install --global-option=build_ext --global-option="-I/opt/homebrew/Cellar/protobuf/21.12/include" --global-option="-L/opt/homebrew/Cellar/protobuf/21.12/lib" gcld3