1

I have version 2.6 of Google protobuffers installed via macports and gcc 4.8 and, when I compile my code (with the -lprotobuf flag), get the following link error:

Undefined symbols for architecture x86_64:
  "google::protobuf::MessageLite::ParseFromString(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      _main in cclSIxVT.o
  "google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))", referenced from:
      protomessages::protobuf_AddDesc_msg_2eproto()       in cc219IO6.o
  "google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)", referenced from:
      protomessages::DatabaseRequestInfo::SerializeWithCachedSizesToArray(unsigned char*) const in cc219IO6.o
  "google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream*)", referenced from:
      protomessages::DatabaseRequestInfo::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const  in cc219IO6.o
  "google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
      protomessages::DatabaseRequestInfo::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)       in cc219IO6.o
  "google::protobuf::DescriptorPool::FindFileByName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const", referenced from:
      protomessages::protobuf_AssignDesc_msg_2eproto()       in cc219IO6.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

My LD_LIBRARY_PATH is correct (otherwise the -lprotobuf flag would not be recognised)

protoc --version returns 2.6.1

I am also compiling with the generated pb.o files so I don't think this is related to , what i know is a common omission.

The command in question I'm using is :

g++  -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-long-long -Wno-variadic-macros -Wno-deprecated -Wno-unused-function -Wno-vla -Wno-unused-variable -std=c++11  -o testbin util/myutil.o util/config.o util/MySemaphore.o network/jobMsg.o network/JobQueue.o network/Message.o network/protocolMsgs.o network/socket/receiver.o network/socket/sender.o blocks/Block.o cluster.o blocks/tc/MVTxCoord.o blocks/tc/StoredProcedure.o blocks/tc/TxCoord.o blocks/tc/IInGroupTC.o blocks/tc/InGroupTCFactory.o blocks/tc/DummyInGroupTC.o blocks/tc/2PLInGroupTC.o blocks/ds/DataService.o blocks/ds/MVDataService.o blocks/ds/HashTableIndex.o blocks/ds/Storage.o blocks/ds/IInGroupDS.o blocks/ds/InGroupDSFactory.o blocks/ds/DummyInGroupDS.o blocks/ds/2PLInGroupDS.o blocks/ds/Lock.o blocks/gm/GroupManager.o blocks/ts/TimestampServer.o blocks/client/Client.o blocks/client/ClientLib.o blocks/client/ClientEnv.o msg.pb.o microbenchmarks/main.o -L/opt/local/lib -lprotobuf -lpthread

I've checked that the library is compiled for 64 bits.

Non-fat file: /opt/local/lib/libprotobuf.a is architecture: x86_64

Any ideas where I am going wrong?

user1018513
  • 1,682
  • 1
  • 20
  • 42

0 Answers0