- 83
- 0
安装protobuf-cpp.3.5.1报错,报错内容如下:
./google/protobuf/stubs/hash.h: In instantiation of 'google::protobuf::hash<long long int>':
./google/protobuf/map_field.h:817: instantiated from here
./google/protobuf/stubs/hash.h:336: error: invalid use of undefined type 'struct std::tr1::hash<long long int>'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/tr1/functional:1101: error: declaration of 'struct std::tr1::hash<long long int>'
./google/protobuf/map_field.h: In member function 'size_t google::protobuf::hash<google::protobuf::MapKey>::operator()(const google::protobuf::MapKey&) const':
./google/protobuf/map_field.h:817: error: no match for call to '(google::protobuf::hash<long long int>) (google::protobuf::int64)'
./google/protobuf/stubs/hash.h: At global scope:
./google/protobuf/stubs/hash.h: In instantiation of 'google::protobuf::hash<long long unsigned int>':
./google/protobuf/map_field.h:821: instantiated from here
./google/protobuf/stubs/hash.h:336: error: invalid use of undefined type 'struct std::tr1::hash<long long unsigned int>'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/tr1/functional:1101: error: declaration of 'struct std::tr1::hash<long long unsigned int>'
./google/protobuf/map_field.h: In member function 'size_t google::protobuf::hash<google::protobuf::MapKey>::operator()(const google::protobuf::MapKey&) const':
./google/protobuf/map_field.h:821: error: no match for call to '(google::protobuf::hash<long long unsigned int>) (google::protobuf::uint64)'
make[2]: * [google/protobuf/dynamic_message.lo] Error 1
make[2]: Leaving directory `/root/protobuf-3.5.1/src'
make[1]: * [all-recursive] Error 1
make[1]: Leaving directory `/root/protobuf-3.5.1'
make: * [all] Error 2
安装步骤:
$ tar -zxvf protobuf-cpp-3.5.1.tar.gz
$ ./configure
$ make
- 共 0 条
- 全部回答
-
Joanna 普通会员 1楼
protobuf-cpp是一个在C++编译器上支持protobuf(Protocol Buffers)的库。以下是一些可能导致protobuf-cpp在Makefile中报错的原因和解决方法:
- 缺少protobuf库:
如果protobuf库在你的Makefile中没有包含,那么编译protobuf-cpp时会报错。在你的Makefile中添加以下行:
protobuf-cpp := protobuf-cpp或者将protobuf-cpp包含到你的项目的include或dependency文件夹中:include protobuf-cpp如果protobuf库已包含在你的项目中,但编译时还是报错,可能是因为protobuf库的版本与你的C++编译器或protobuf-cpp的版本不兼容。在Makefile中,你可以使用proto_cxx_library或protocxx_library来指定protobuf库的版本:proto_cxx_library := $(protobuf-cpp) proto_cxx_library := $(proto_cxx_library)/$(PROTOBUF_VERSION) proto_cxx_library := $(proto_cxx_library)/$(PROTOBUF_VERSION)-$(CXX_COMPILER_VERSION)
例如,如果你的protobuf库为
protocxx,且你使用的是C++17编译器,你可以在你的Makefile中使用以下版本的proto_cxx_library:proto_cxx_library := $(protobuf-cpp)/$(PROTOBUF_VERSION)-$(CXX_COMPILER_VERSION)-
protobuf-cpp编译错误: protobuf-cpp可能在编译过程中出现错误,这可能导致编译器报错。以下是一些可能的错误类型和解决方案:
-
拼写错误:在编译protobuf-cpp时,确保所有protobuf头文件(例如
protoc.h)的拼写都是正确的。例如,<protobuf.h>可能被误拼为<protoc.h.proto>。 -
缺少.proto文件:在编译protobuf-cpp时,确保所有proto文件(例如
my.proto)都被正确地编译。检查每个proto文件是否在include或dependency文件夹中,并确保它们被正确地链接到protobuf库中。 -
错误的protobuf头文件:确保你的protobuf头文件中没有包含必要的注释、结构体定义或其他定义。例如,如果你的protobuf头文件中包含
struct MyStruct,但没有在protobuf文件中定义,编译器可能会抛出错误。 -
错误的protobuf结构体定义:在protobuf结构体定义中,确保所有的字段名、属性名、方法名等都是有意义的,并且遵循protobuf的命名规则。例如,如果你的protobuf结构体定义中使用了
field1,但未定义该字段,编译器可能会抛出错误。 -
缺少proto编译选项:在编译protobuf-cpp时,可能需要使用特定的protobuf编译选项。例如,如果你在编译时使用了
--cpp_out选项,但没有指定protobuf库的输出目录,编译器可能会报错。 -
错误的protobuf编译器选项:在编译protobuf-cpp时,可能需要使用特定的protobuf编译器选项。例如,如果你在编译时使用了
--cpp_incompatible选项,但没有指定protobuf库的不兼容选项,编译器可能会报错。 -
错误的protobuf库路径:确保protobuf库的路径在Makefile中正确地指定。例如,如果你在你的Makefile中指定了
protobuf-cpp的路径,但在编译时指定的路径与protobuf库的实际路径不一致,编译器可能会报错。 -
缺少protobuf库的依赖项:在编译protobuf-cpp时,可能需要使用特定的protobuf库依赖项。例如,如果你的protobuf库没有包含在你的项目中,但编译protobuf-cpp时需要使用特定的protobuf库依赖项,例如
google/protobuf,则需要在你的Makefile中指定这些依赖项:
makefile proto_cxx_library := $(protobuf-cpp)/$(PROTOBUF_VERSION)-$(CXX_COMPILER_VERSION)-$(CXX_COMPILER的那个版本) proto_cxx_library := $(proto_cxx_library)/$(PROTOBUF_VERSION)-$(CXX_COMPILER的那个版本)-$(CXX_COMPILER的那个版本) proto_cxx_library := $(proto_cxx_library)/$(PROTOBUF_VERSION)-$(CXX_COMPILER的那个版本)-$(CXX_COMPILER的那个版本)-$(CXX_COMPILER的那个版本)-$(CXX_COMPILER的那个版本)注意:在使用protobuf-cpp依赖项时,你需要将
CXX_COMPILER的那个版本替换为你的实际C++编译器的版本。以上是可能导致protobuf-cpp在Makefile中报错的一些常见原因和解决方案,如果问题仍然存在,可能需要对protobuf-cpp的源代码或编译器进行更深入的检查和调试。
- 缺少protobuf库:
如果protobuf库在你的Makefile中没有包含,那么编译protobuf-cpp时会报错。在你的Makefile中添加以下行:
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
