问题
I'm currently getting an error which points me to these lines in the header file produced by protoc:
#if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
But my protoc version matches the one above:
protoc --version
libprotoc 2.6.1
What am I doing wrong?
Originally my protoc version was 3.0.0 then reinstalled it by syncing back to 2.6.1 and doing the steps; make distclean, ./configure , make, make install to install the desired 2.6.1 version. I needed the older version since that's the one installed in our servers.
回答1:
The problem is that the installed headers on your system (in /usr/include/google/protobuf or /usr/local/include/google/protobuf) are from a newer version of Protocol Buffers than your protoc
. It may be the case that you have both versions installed in different locations, and the wrong one is being used.
But my protoc version matches the one above:
Yes, because that code was generated by your protoc
, and it knows its own version. The code is asking: "Is my version (2006001) less than the minimum version which the installed headers claim is required (GOOGLE_PROTOBUF_MIN_PROTOC_VERSION)?"
来源:https://stackoverflow.com/questions/35744529/protocol-buffer-error-on-compile-during-google-protobuf-min-protoc-version-check