c++ 调用protobuf和grpc 遇到的问题

c++ 调用protobuf和grpc

刚开始,由于各种原因,使用的是protobuf3.0 和 grpc1.0

grpc编译正常,调用的时候报异常,找不大Wait()等几个方法

google一下,找到了:https://github.com/grpc/grpc/issues/8606

主要原因就是文件名冲突了,导致编译的时候没有把grpc++内的部分功能加入
所以找不大函数

重新下载了grpc1.01,这个ok,没问题了,但是protobuf又出问题了:
1>model.grpc.pb.obj : error LNK2001: 无法解析的外部符号 "private: static int google::protobuf::io::CodedInputStream::default_recursion_limit_" (?default_recursion_limit_@CodedInputStream@io@protobuf@google@@0HA)
1>model.pb.obj : error LNK2001: 无法解析的外部符号 "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const * const google::protobuf::internal::empty_string_" (?empty_string_@internal@protobuf@google@@3PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@EB)
1>model.pb.obj : error LNK2001: 无法解析的外部符号 "__int64 google::protobuf::internal::empty_string_once_init_" (?empty_string_once_init_@internal@protobuf@google@@3_JA)
1>D:\work\facecheck\server\src\DriverShifts\x64\Release\DriverMonitor.exe : fatal error LNK1120: 3 个无法解析的外部命令

打开dll,搜索default_recursion_limit_@CodedInputStream@io@protobuf@google, 找到1个,说明dll是没问题的

再google,找到了这个:https://github.com/google/protobuf/issues/812

先设置 属性-> c/c++ -> 优化 -> 内联函数扩展,设置为 已禁用

再编译,还是一样的问题,继续看上面那个网页,有个人指出了另外一个方法:
https://stackoverflow.com/questions/13733604/visual-studio-2010-c-w-google-protocol-buffers-cannot-find-60-externals-can/16065204#16065204

就是在预处理器 -> 预处理器定义中添加PROTOBUF_USE_DLLS
重新编译,问题解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值