协议缓冲区错误版本



我正在尝试安装 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

但是在我的系统头(/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 返回 libprotoc3.2.0

所以我安装了 3.2 版本,但系统标题没有更新。 一位用户在上一篇文章中评论说:"我想出了一种方法,通过在 PATH 变量中首先指定我想要的 protobuf,而不必删除其他版本的 protobuf(其他事情取决于旧版本(。

有人可以一步一步地解释我如何遵循这一点吗? 或者,我可以更新系统标头吗?有许多元素连接到libprotoc,所以我想避免损坏它们。

谢谢

我在电脑上解决了这个问题,也许它可以帮助你。我的环境是 Ubuntu16.04,在安装 Caffe 之前我安装了 Anaconda(适用于 python2.7(。碰巧我使用 conda 来安装 libprotobuf-dev,这导致与 caffe 的"sudo apt-get install libprotobuf-dev"命令冲突,因为"apt-get"和 conda 在我的计算机上安装不同,可以通过"定位 protobuf"找到,所以我删除了 Anaconda 版本的 libprotobuf,再也没有问题发生。

conda uninstall libprotobuf
conda uninstall protobuf

当你在安装Caffe 之前安装 tensorflow 时,由于 libprotobuf 冲突,这个问题也会发生。

最新更新