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

protoc flag to set "-I $PROTOBUF_INSTALL_DIR/include" implicitly #5364

Closed
marcusljx opened this issue Nov 15, 2018 · 5 comments
Closed

protoc flag to set "-I $PROTOBUF_INSTALL_DIR/include" implicitly #5364

marcusljx opened this issue Nov 15, 2018 · 5 comments
Assignees
Labels
inactive Denotes the issue/PR has not seen activity in the last 90 days. protoc

Comments

@marcusljx
Copy link

What language does this apply to?
protoc compiler

Describe the problem you are trying to solve.
Protobuf installations typically come with the include directory that has most of the necessary protobuf files for common types like google.protobuf.Empty.

However, this directory is not included by default, nor is there a simple way to include them during protoc invocation.

Describe the solution you'd like

  • add a new flag --import-default-includes to the protoc compiler to implicitly add -I $(which protoc)/../include (this assumes unzip method, installations via package managers have different structure).
  • This will allow users to automatically set the import path to the correct set of supported protobuf files that came with the compiler, by simply doing
protoc --import-default-includes -I./path/to/my/other/includes my_file.proto

Describe alternatives you've considered
stub42/protobuf-snap#1 <-- proposed setting a global $PROTOBUF_HOME during installation via snap so that users can do

protoc -I${PROTOBUF_HOME}/include ....

but this is not a universal solution as it would only work for snap

Additional context
nil

@acozzette acozzette self-assigned this Nov 19, 2018
@fdcds
Copy link

fdcds commented Sep 17, 2019

I unpacked protoc to $HOME/.local and am also running into the issue where the included protobuf files cannot be found.

If protoc was automatically adding $HOME/.local/include:$PREFIX/local/include:$PREFIX/include (with protoc installed to $PREFIX/bin) to the import path, that would be very convenient.

@elharo elharo added the protoc label Sep 20, 2021
@OliverCardoza
Copy link

OliverCardoza commented Mar 7, 2022

Another alternative which does not depend on protoc installation method is to reference protocolbuffers/protobuf directly when you are building. I added https://github.com/protocolbuffers/protobuf as a submodule of my repo. Then when calling protoc I add:

    -I vendor/github.com/protocolbuffers/protobuf/src

I'm not familiar C/C++ use of include directories and this feels more appropriate way to reference dependencies (make it explicit).

@AtricoSoftware
Copy link

I will add my support to the first solution, ie an environment variable with the default import path. This could be configured to include multiple paths (like the PATH variable)
I am currently trying to create a machine independent build script. I cannot specify the import location explicitly as it depends where the relevant files were installed on the current machine (my dev machine, colleague's machine, build server, etc)

Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label May 12, 2024
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Denotes the issue/PR has not seen activity in the last 90 days. protoc
Projects
None yet
Development

No branches or pull requests

6 participants