协议缓冲区错误版本

时间:2017-07-12 08:54:57

标签: c++ protocol-buffers protoc

我试图安装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.

我在论坛中遵循了许多提议的方法,我认为讨论了最相似的问题in this post

在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从终端返回libprotoc 3.2.0

所以我安装了3.2版本,但系统标头没有更新。 上一篇文章中的一位用户发表评论&#39;我通过在PATH变量中首先指定我想要的protobuf来找到一种方法,而不必删除其他版本的protobuf(其他东西取决于旧版本)。&#39 ;

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

由于

1 个答案:

答案 0 :(得分:0)

我在电脑上解决了这个问题,也许它可以帮到你。我的环境是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冲突,也会发生此问题。