在同一个C ++项目中链接两个不同版本的protobuf库 [英] Link two different version of protobuf library in the same C++ project

查看:81
本文介绍了在同一个C ++项目中链接两个不同版本的protobuf库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在同一个c ++项目中同时使用protobuf 2.6和3.0库并将它们链接在一起吗?

can I use both protobuf 2.6 and 3.0 libs in the same c++ project and link them together?

推荐答案

您不能将两个不同版本的libprotobuf链接到同一程序中.(在某些操作系统上可能是可行的,但在Linux上绝对不能使用,因为具有相同名称的声明会相互覆盖.在Windows或Mac上可能可以工作,但这可能不是一个好主意.依靠它.)

You cannot link two different versions of libprotobuf into the same program. (It may be possible on some OS's, but it definitely won't work on Linux, where the declarations with the same names would overwrite each other. It may be possible to make work on Windows or Mac, but it's probably not a good idea to rely on this.)

但是,您不需要这样做.libprotobuf 3.x支持"proto3"和"proto2"语法.只要您可以从源代码中重建代码(包括重新生成.pb.h和.pb.cc文件),就可以使用3.x版重建所有内容,即使某些proto文件使用了proto2-exclusive功能.

However, you don't need to do this. libprotobuf 3.x supports both "proto3" and "proto2" syntax. As long as you can rebuild your code from source (including regenerating the .pb.h and .pb.cc files), you should be able to rebuild everything using version 3.x, even if some of the proto files use proto2-exclusive features.

这篇关于在同一个C ++项目中链接两个不同版本的protobuf库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆