尝试制作Mosh源代码时,协议缓冲版本错误

时间:2013-07-08 11:09:45

标签: makefile protocol-buffers

我一直在尝试在以下系统上安装Mosh(移动shell):

[ptedder@ukch-dev-lndt03 mosh-1.2.4]$ cat /etc/*-release
CentOS release 5.3 (Final)

它配置正常,但是当我尝试制作Mosh 1.2.4(或1.2.0)时,我收到以下错误:

make  all-recursive
make[1]: Entering directory `/home/ptedder/bin/mosh-1.2.4'
Making all in src
make[2]: Entering directory `/home/ptedder/bin/mosh-1.2.4/src'
Making all in protobufs
make[3]: Entering directory `/home/ptedder/bin/mosh-1.2.4/src/protobufs'
make  all-am
make[4]: Entering directory `/home/ptedder/bin/mosh-1.2.4/src/protobufs'
  CXX    userinput.pb.o
In file included from userinput.pb.cc:5:
userinput.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
userinput.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
userinput.pb.h:14:2: error: #error your headers.
make[4]: *** [userinput.pb.o] Error 1
make[4]: Leaving directory `/home/ptedder/bin/mosh-1.2.4/src/protobufs'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/ptedder/bin/mosh-1.2.4/src/protobufs'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/ptedder/bin/mosh-1.2.4/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ptedder/bin/mosh-1.2.4'
make: *** [all] Error 2

这是使用协议缓冲区版本2.4.1(建议它可能硬编码到mosh这里#import <string> in ios? Protobuf c++ in ios)但我已经尝试使用协议缓冲区版本2.3.0和2.5.0并且他们都给了以下错误:

"This file was generated by a newer version of protoc which is
userinput.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
userinput.pb.h:14:2: error: #error your headers."

任何想法?

2 个答案:

答案 0 :(得分:4)

问这个问题两年后,我仍然找不到一个好的解决方案。我有同样的问题,并最终在一些侦探工作后修复它。问题是:我从git repo https://github.com/google/protobuf获得了最新版本的protobuf。当我尝试构建我的项目时,它抛出了qmp的答案中显示的错误,

#if GOOGLE_PROTOBUF_VERSION < 2004000                                           
#error This file was generated by a newer version of protoc which is...  

我正在构建其他人编写的代码,并且在他们的.proto文件中,他们没有指定版本。默认为syntax = "proto2";我在syntax = "proto3";声明之前向.proto文件添加了package,并删除了optionalrequired个关键字的所有实例,因为它们不是第3版语法的一部分。然后从命令行重新生成protobuf输出。

prompt@ubuntu$ protoc --cpp_out=. project.proto

这更新了protoc生成的所有文件到版本3,解决了这个问题。

答案 1 :(得分:0)

如果你看一下userinput.pb.h,你会注意到它是

#if GOOGLE_PROTOBUF_VERSION < 2004000                                           
#error This file was generated by a newer version of protoc which is            

因此protobuf-2.4.1足以支持mosh-1.2.4。如果您仍然收到错误,那么可能会有一个stray protobuf安装,可能是/usr/local中的内容。