协议缓冲区错误版本

Protocol Buffer Error version

我正在尝试安装 Caffe 库,但由于我的系统中安装了错误的 protobuf 版本,我遇到了编译问题。

In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
 #error This file was generated by an older version of protoc which is
  ^
.build_release/src/caffe/proto/caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
 #error incompatible with your Protocol Buffer headers.  Please
  ^
.build_release/src/caffe/proto/caffe.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
 #error regenerate this file with a newer version of protoc.

我遵循了论坛中提出的许多方法,我认为讨论了最相似的问题

在caffe.pb.h控件中是:

#if 3002000 < 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

但是在我的系统中 header (/usr/include/google/protobuf/stubs/common.h):

The current version, represented as a single integer to make comparison
easier:  major * 10^6 + minor * 10^3 + micro
define GOOGLE_PROTOBUF_VERSION 2005000

从终端命令 protoc --version returns libprotoc 3.2.0.

所以我安装了3.2版本但是系统header没有更新。 之前 post 中的一位用户评论 '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).'

谁能一步一步地解释我,我该怎么做? 或者我可以更新系统 headers 吗?有很多元素连接到 libprotoc,所以我想避免损坏它们。

谢谢

我在我的电脑上解决了这个问题,也许它能帮到你。我的环境是Ubuntu16.04,在安装Caffe之前先安装了Anaconda(for python2.7)。正好我用conda安装了libprotobuf-dev,导致和caffe的'sudo apt-get install libprotobuf-dev'命令冲突,因为'apt-get'和我电脑上安装的conda不一样,可以通过'locate protobuf'找到,所以我删除了Anaconda版本的libprotobuf,没有再出现问题。

conda uninstall libprotobuf
conda uninstall protobuf

在安装Caffe之前安装tensorflow时,也会出现这个问题,因为libprotobuf冲突