繁体   English   中英

使用g ++-5时protobuf无法在osx上编译

[英]protobuf will not compile on osx when using g++-5

请参阅以下基于protobufc ++教程的示例项目。

https://github.com/cskeeters/protobuf_addressbook

我在osx 10.10.5上使用以下命令安装了protobuf:

brew install protobuf

我也通过brew install安装了g ++-5,但是已经有一段时间了。 为什么不能用g ++编译?

失败的命令是:

g++-5 -g -O2 -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf -D_THREAD_SAFE -o main main.o addressbook.pb.o

结果是: Undefined symbols for architecture x86_64: "google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))", referenced from: tutorial::protobuf_AddDesc_addressbook_2eproto() in addressbook.pb.o ...

我正在测试。 我没有理由不在osx上使用clang ++。 我只是好奇。

这是因为clang,g ++-5和g ++-4.x的ABI不同。 您首先需要使用g ++-5重新编译protobuf本身,然后才使用-lprotobuf将其链接到您的程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM