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
重新编译,问题解决