Reputation: 1488
See the following sample project based on the c++ tutorial on protobuf.
https://github.com/cskeeters/protobuf_addressbook
I installed protobuf on osx 10.10.5 using:
brew install protobuf
I installed g++-5 via brew install also, but it's been a while. Why won't this won't compile with g++?
The command that fails is:
g++-5 -g -O2 -L/usr/local/Cellar/protobuf/2.6.1/lib -lprotobuf -D_THREAD_SAFE -o main main.o addressbook.pb.o
The result is:
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
...
I'm just testing. I have no reason not to use clang++ on osx. I'm just curious.
Upvotes: 0
Views: 362
Reputation: 8401
It is because different ABI for clang, g++-5 and g++-4.x. You need first to recompile protobuf itself with g++-5, and only then link it to your program with -lprotobuf
.
Upvotes: 1