Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is missing build/linking instructions #10820

Closed
hk0i opened this issue Oct 26, 2022 · 6 comments
Closed

Documentation is missing build/linking instructions #10820

hk0i opened this issue Oct 26, 2022 · 6 comments

Comments

@hk0i
Copy link

hk0i commented Oct 26, 2022

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:

  1. Install via homebrew
brew install protobuf
  1. Read how to write a message

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?

  1. Searching Google on "how to build protobuf"
  2. 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.
@hk0i hk0i added the untriaged auto added to all issues by default when created. label Oct 26, 2022
@hk0i hk0i changed the title Missing build instructions in documentation Documentation is missing build instructions Oct 26, 2022
@hk0i hk0i changed the title Documentation is missing build instructions Documentation is missing build/linking instructions Oct 26, 2022
@hk0i
Copy link
Author

hk0i commented Oct 26, 2022

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.

@acozzette acozzette added c++ documentation help wanted and removed untriaged auto added to all issues by default when created. labels Nov 2, 2022
@deannagarcia
Copy link
Member

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!

@nikiexpo
Copy link

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

@deannagarcia
Copy link
Member

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.

@DotIN13
Copy link

DotIN13 commented May 29, 2023

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 

@osnortb
Copy link

osnortb commented Jun 2, 2023

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.(google/cld3#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

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

No branches or pull requests

6 participants