How to compile *.pb.cc as *.o?

176 views
Skip to first unread message

lzhshen

unread,
May 26, 2011, 4:29:50 AM5/26/11
to Protocol Buffers
Take addressbook.proto as example, following command does not work:

c++ addressbook.pb.cc -o addressbook.o `pkg-config --cflags
protobuf`

Following are error output:

/usr/lib64/gcc/x86_64-unknown-linux/4.1.2/../../../../lib64/crt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'
/tmp/ccjvcDzQ.o: In function `tutorial::Person::SharedDtor()':
addressbook.pb.cc:(.text+0x64a): undefined reference to
`google::protobuf::internal::kEmptyString'
addressbook.pb.cc:(.text+0x67f): undefined reference to
`google::protobuf::internal::kEmptyString'
/tmp/ccjvcDzQ.o: In function
`tutorial::Person_PhoneNumber::SharedDtor()':
addressbook.pb.cc:(.text+0x6c2): undefined reference to
`google::protobuf::internal::kEmptyString'
/tmp/ccjvcDzQ.o: In function `tutorial::Person_PhoneNumber::ByteSize()
const':


Have any idea?

Adam Skutt

unread,
May 26, 2011, 6:34:45 AM5/26/11
to lzhshen, Protocol Buffers

Yes, you tried to link the file into an executable instead of an
object file, and the linker is complaining because it cannot find a
valid main(), among many other functions. GCC requires the '-c'
option to tell it to output an object file instead of an executable.

Adam

Reply all
Reply to author
Forward
0 new messages