22

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.

the_qbf
  • 358
  • 1
  • 2
  • 12
  • 1
    Are you sure your previously (with 3.0.0 version) generated protobuf headers were removed/updated? – πάντα ῥεῖ Mar 02 '16 at 10:30
  • Yup, I deleted those 3.0.0 headers explicitly. I also checked the file and the check validation for the version is as written above with the 2006001 version comparison – the_qbf Mar 02 '16 at 14:34

1 Answers1

23

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)?"

Kenton Varda
  • 41,353
  • 8
  • 121
  • 105
  • 2
    Is there a way to check which version of the headers were installed in my system? I tried looking at the files themselves and can't find any hints on what version it is. – the_qbf Mar 03 '16 at 13:59
  • 10
    @the_qbf: Yes, look at `google/protobuf/stubs/common.h` and look for the `GOOGLE_PROTOBUF_VERSION` macro around 100 lines in. – Kenton Varda Mar 04 '16 at 19:00
  • 1
    Competent and helpful answer, helped me to figure out what was my problem. Thank you, sir! – Software Craftsman Feb 28 '17 at 15:15
  • Hi, any way to specify to a program which version of `protoc` to be used? I also have two versions of protoc, and would want to specify to `caffe` which one to use. – AruniRC Apr 06 '17 at 17:34
  • @AruniRC it would be up to the program's build system to provide you with a way to specify. There is no general way, other than having only one installed at a time. – Kenton Varda Apr 10 '17 at 00:43
  • 1
    @KentonVarda thanks! I figured out a way by specifying the protobuf I want first in the PATH variable, without having to remove the other version of protobuf (other things depended on that old version). – AruniRC Apr 10 '17 at 02:57
  • or if you did like me: you might have updated the cc file but forgotten to update the header file – kristian mo Oct 23 '17 at 14:23