码迷,mamicode.com
首页 > 编程语言 > 详细

google protobuf c++ 反射

时间:2019-12-31 10:19:34      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:source   force   ofo   read   cts   obj   ORC   col   figure   

const Descriptor *desc = DescriptorPool::generated_pool()->FindMessageTypeByName(msg_name);
assert(desc);

  上述示例代码,desc结果为空。最后在github找到答案

上面链接中给出的解答是

OK, finally I figured out that there is no black magic and it‘s just a linker problem, I compiled the proto sources into a static library, seems the linker automatically optimized out those objs not used when linking against the static library. I follow this thread and it fixes the problem

另外一个人提出的问题和得到的回答

Q:how to config on Visual Studio,when build a static library?

A:An alternative is to reference these protos types somewhere in your code so they don‘t get stripped by the linker.(意思就是在之前的代码中使用过这个proto)

google protobuf c++ 反射

标签:source   force   ofo   read   cts   obj   ORC   col   figure   

原文地址:https://www.cnblogs.com/IGNB/p/12122791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!