• google protobuf c++ 反射


    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)

    可以图形化看到的东西坚决不会用命令行ORZ

  • 相关阅读:
    Android Zygote介绍
    Android binder介绍(下)
    Android binder介绍(上)
    Android init介绍(下)
    Android init介绍(上)
    Android 网络服务介绍
    Linux代理服务器使用
    Linux ALSA介绍
    ZigBee MAC层(下)
    ZigBee MAC层(上)
  • 原文地址:https://www.cnblogs.com/IGNB/p/12122791.html
Copyright © 2020-2023  润新知