协议缓冲区错误版本

Luc*_*uca 6 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.
Run Code Online (Sandbox Code Playgroud)

我在论坛中遵循了许多提议的方法,我认为在这篇文章中讨论了最类似的问题.

在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
Run Code Online (Sandbox Code Playgroud)

但是在我的系统标题中(/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
Run Code Online (Sandbox Code Playgroud)

从终端命令protoc --version返回libprotoc 3.2.0.

所以我安装了3.2版本但系统头文件没有更新.上一篇文章中的一位用户评论说'我想通过在PATH变量中首先指定我想要的protobuf,而不必删除其他版本的protobuf(其他依赖于旧版本的东西).

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

谢谢

For*_*ang 2

我在我的电脑上解决了这个问题,也许它可以帮助你。我的环境是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
Run Code Online (Sandbox Code Playgroud)

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