protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Missing google/protobuf/runtime_version.h

Open dpservis opened this issue 1 year ago • 13 comments

What version of protobuf and what language are you using? Version: v27.2 through vcpkg using vcpkg install protobuf protobuf:x64-windows Language: C++

What operating system (Linux, Windows, ...) and version? Windows 11 What runtime / compiler are you using (e.g., python version or gcc version) MSVC 2022 v147 What did you do? Steps to reproduce the behavior:

  1. Generate code from schemas
  2. Try to use the generated code

What did you expect to see Code compiles What did you see instead? Missing google/protobuf/runtime_version.h Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs). error C1083: Cannot open include file: 'google/protobuf/runtime_version.h': No such file or directory Anything else we should know about your project / environment

dpservis avatar Jun 27 '24 06:06 dpservis

Can you clarify how you got the version of protobuf? Looks like vcpkg only has up to 4.25.1 for protobuf? https://vcpkg.io/en/package/protobuf

zhangskz avatar Jul 01 '24 15:07 zhangskz

I am experiencing the same issue. Installed via vcpkg, version v4.25.1.

poyen-wu avatar Jul 02 '24 00:07 poyen-wu

Switching to a earlier version of protoc (25.1 works for me) downloaded from the release page solved the issue. The Readme indicates to install the runtime via vcpkg and download the compiler from the release page, but does not specify the version needs to match. As a user I did not expect the latest version of the compiler to not work with the runtime installed with the officially suggested method.

poyen-wu avatar Jul 02 '24 04:07 poyen-wu

Our C++ cross version runtime policy documents that protoc/gencode version and runtime version must match: https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp

@Logofile We make some reference to this in the Binary Compatibility Warning section but could probably clarify this and link to this page in the C++ readme: https://github.com/protocolbuffers/protobuf/tree/main/src

zhangskz avatar Jul 02 '24 16:07 zhangskz

Same issue.....

Abdullah-AlAttar avatar Jul 04 '24 11:07 Abdullah-AlAttar

Yes, this was my mistake because of version mismatch. Unfortunately vcpkg does not include the runtime and I checked out the corresponding code but at some point I updated.

dpservis avatar Jul 04 '24 15:07 dpservis

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. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Oct 03 '24 10:10 github-actions[bot]

Facing same issue. please suggest the work around for this. working on Linux (Ubuntu 22) protoc --version libprotoc 29.0-dev

I have installed the protobuf using bazel build following the instructions in the link --> installation link error message:

[ 62%] Built target DefaultPublisher
...
...
...

/home/xyzw/build/deps/proto/xyzw/Attribute.pb.h:14:10: fatal error: google/protobuf/runtime_version.h: No such file or directory
   14 | #include "google/protobuf/runtime_version.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake: *** [Makefile:91: all] Error 2

Strange21 avatar Oct 07 '24 07:10 Strange21

Also facing the same issue. vcpkg has protobuf, and on ubuntu libprotobuf-dev and protobuf-compiler are installed. How do you fix this?

nravic avatar Oct 09 '24 13:10 nravic

I had the same problem on OSX when installing protobuf via homebrew; the secret is that for some reason on M1 systems, homebrew doesn't put the protobuf includes in /usr/include, and so you must use pkg-config --cflags to apply the right include paths or your build doesn't work.

davidgiven avatar Oct 15 '24 21:10 davidgiven

I observe the same problem, for some reason after installation it does not find this header file

mrmomenticus avatar Oct 16 '24 12:10 mrmomenticus

We suggest to try updating the protobuf library version to match the proto-compiler version.

There might be older protobuf library versions installed and somehow linked to the new gencode/protoc. This isn't compatible and will throw the error.

Please provide more details of how protobuf is being compiled and used, e.g. bazel cmake..?, so that we know how to update our installation guide.

For bazel, probably also try setting up the WORKSPACE file to use the more recent protobuf.

lastly, the fastest workaround might be downgrading the protoc version to < 27.0.

shaod2 avatar Oct 16 '24 15:10 shaod2

@shaod2 I will add information:

System: Debian GNU/Linux 11 (docker) Protocol version: libprotoc 27.0(I also tried 28.2) GRPC version: v1.67(also tried 1.65)

Connecting grpc via Cmake:

set(protobuf_MODULE_COMPATIBLE TRUE)
set(ABSL_ENABLE_INSTALL ON)
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
message(STATUS "PROTOBUF_VERSION: " $PROTOBUF_VERSION)
include(FetchContent)
FetchContent_Declare(
  gRPC
  GIT_REPOSITORY https://github.com/grpc/grpc
  GIT_TAG        v1.67.0
)

Attempt 1: I downloaded the release locally and placed it on the path /usr/local 'include/*' and /usr/local bin/protocol, launched the protocol utility and after that an error appeared in the generated messages.

Attempt 2: I did everything according to the instructions https://github.com/protocolbuffers/protobuf/blob/main/src/README.md via bazel, after copying the /usr/local/bin files

Attempt 3: I found that the runtime_version.h file is not in the entire file system and in the project, but it is in the source protobuf file. I copied it and put it in the build folder at the path /build/_deps/grpc-src/third_party/protobuf/src/google/protobuf/runtime_version.h after that, the project began to be assembled, but fell on version checks.

#if PROTOBUF_VERSION != 5027000
#error "Protobuf C++ gencode is built with an incompatible version of"
#error "Protobuf C++ headers/runtime. See"
#error "https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp"
#endif

where PROTOBUF_VERSION = 5027000

mrmomenticus avatar Oct 17 '24 08:10 mrmomenticus

I'm facing the same problem too. I'm using 28.3 on debian linux.

It's easy to reproduce with the following steps:

$ wget https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip
$ unzip protoc-28.3-linux-x86_64.zip
$ bin/protoc -I=. --cpp_out=. addressbook.proto
$ g++ -I include/ addressbook.pb.cc -o addressbook.pb.o

(addressbook.proto is from the demo here) The last step will throws:

In file included from addressbook.pb.cc:6:
addressbook.pb.h:14:10: fatal error: google/protobuf/runtime_version.h: No such file or directory
   14 | #include "google/protobuf/runtime_version.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

libenchao avatar Oct 29 '24 11:10 libenchao

I'm going through the same problem as well. I'm trying to use protocol buffer in a C++ project on 64-bit Windows.

Error C1083 'google/protobuf/runtime_version.h': No such file or directory c:\src\samples\sample01\addressbook.pb.h, line:14

GustavoEGPerez avatar Nov 04 '24 13:11 GustavoEGPerez

facing the same issue and i re-install the grpc&protobuf and regenerate the .proto file , it works

Lojc6 avatar Nov 15 '24 14:11 Lojc6

Thanks to all the responders for providing context for the issues that you're experiencing. This will help me to update the documentation with more specificity to help others avoid this issue.

Logofile avatar Nov 19 '24 15:11 Logofile