protoc generates a .pb.cc file.  You need to compile that too.

On Tue, Apr 6, 2010 at 6:44 PM, Bo Zhang <zhan...@google.com> wrote:

> Hi guys, here I come again with errors I can't figure out.
>
>
> Basically I copied the code for "writing a message" from tutorial and
> pasted it into write.cc under directory "examples". write.cc is
> supposed to invoke addressbook
>
> When I try to compile write.cc, I got the following:
>
>
>
> protobuf-2.3.0/examples$ c++ write.cc `pkg-config --cflags --libs
> protobuf`
> /tmp/cc62Lqqa.o: In function `main':
> write.cc:(.text+0x45c): undefined reference to
> `tutorial::AddressBook::AddressBook()'
> write.cc:(.text+0x673): undefined reference to
> `tutorial::AddressBook::~AddressBook()'
> write.cc:(.text+0x692): undefined reference to
> `tutorial::AddressBook::~AddressBook()'
> /tmp/cc62Lqqa.o: In function
> `google::protobuf::internal::GenericTypeHandler<tutorial::Person>::New()':
> write.cc:
>
> (.text._ZN6google8protobuf8internal18GenericTypeHandlerIN8tutorial6PersonEE3NewEv[google::protobuf::internal::GenericTypeHandler<tutorial::Person>::New()]
> +0x1c): undefined reference to `tutorial::Person::Person()'
> /tmp/cc62Lqqa.o: In function `tutorial::Person::mutable_name()':
> write.cc:
>
> (.text._ZN8tutorial6Person12mutable_nameEv[tutorial::Person::mutable_name()]
> +0x25): undefined reference to `tutorial::Person::_default_name_'
> /tmp/cc62Lqqa.o: In function
> `tutorial::Person::set_email(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)':
> write.cc:
>
> (.text._ZN8tutorial6Person9set_emailERKSs[tutorial::Person::set_email(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)]+0x29):
> undefined reference to `tutorial::Person::_default_email_'
> /tmp/cc62Lqqa.o: In function
> `tutorial::Person_PhoneNumber::set_number(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)':
> write.cc:
>
> (.text._ZN8tutorial18Person_PhoneNumber10set_numberERKSs[tutorial::Person_PhoneNumber::set_number(std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)]+0x29):
> undefined reference to
> `tutorial::Person_PhoneNumber::_default_number_'
> /tmp/cc62Lqqa.o: In function
>
> `google::protobuf::internal::GenericTypeHandler<tutorial::Person_PhoneNumber>::New()':
> write.cc:
>
> (.text._ZN6google8protobuf8internal18GenericTypeHandlerIN8tutorial18Person_PhoneNumberEE3NewEv[google::protobuf::internal::GenericTypeHandler<tutorial::Person_PhoneNumber>::New()]
> +0x1c): undefined reference to
> `tutorial::Person_PhoneNumber::Person_PhoneNumber()'
> /tmp/cc62Lqqa.o: In function
> `tutorial::Person_PhoneNumber::set_type(tutorial::Person_PhoneType)':
> write.cc:
>
> (.text._ZN8tutorial18Person_PhoneNumber8set_typeENS_16Person_PhoneTypeE[tutorial::Person_PhoneNumber::set_type(tutorial::Person_PhoneType)]
> +0x13): undefined reference to
> `tutorial::Person_PhoneType_IsValid(int)'
> collect2: ld returned 1 exit status
> protobuf-2.3.0/examples$
>
>
>
> What did I do wrong?
>
>
> Thanks a lot
>
> Zhang Bo
>
>
>
>
>
> On Apr 7, 9:20 am, Bo Zhang <zhan...@google.com> wrote:
> > Following up to the previous test failure. I have cleaned to old one
> > and downloaded a fresh one. This time make check passed all test.
> >
> > I'm trying to make install and testing examples now. I will post the
> > result later
> >
> > However it would be nice to understand the reason behind the failure.
> >
> > Thanks
> >
> > Zhang Bo
> >
> > On Apr 7, 8:57 am, Bo Zhang <zhan...@google.com> wrote:
> >
> >
> >
> > > Hi Steven,
> >
> > > Thanks for your reply. In deed I was following the instructions.
> >
> > > Anyway I had a rerun. Make check fails one test (again, which I forgot
> > > to mention before), as shown below:
> >
> > > [==========] 729 tests from 102 test cases ran. (2899 ms total)
> > > [  PASSED  ] 728 tests.
> > > [  FAILED  ] 1 test, listed below:
> > > [  FAILED  ] BootstrapTest.GeneratedDescriptorMatches
> > > .
> > > .
> > > .
> > > .
> > > ==========================================
> > > 1 of 5 tests failed
> > > Please report to protobuf@googlegroups.com
> > > ==========================================
> >
> > > Could anyone explain to me why this test fails? Seems to me that
> > > there's something wrong with version. How could I fix this?
> >
> > > Thanks a lot
> >
> > > Zhang Bo
> >
> > > On Apr 6, 10:07 pm, Steven Ong <stevenong2...@gmail.com> wrote:
> >
> > > > Hi,
> >
> > > > You need to read and follow the instruction from the <DIR>/README.txt
> (<DIR>
> > > > is where your protobuf-x.x.x resding) file to
> > > > configure/compile/check/install the package before you can use it
> (That for
> > > > the C++ portion). For the Java portion, you need to read and follow
> the
> > > > instruction in the <DIR>java/README.txt to build the library, after
> that,
> > > > install your *.jar file according to the JAVA standard to use it.
> >
> > > > Hope this would help,
> > > > Steven
> >
> > > > On Tue, Apr 6, 2010 at 2:19 AM, Bo Zhang <zhan...@google.com> wrote:
> > > > > Hi,
> >
> > > > > I'm new to both protocol buffer and to linux system, so excuse me
> for
> > > > > simple questions. :)
> >
> > > > > I try to "make" in the example directory. I got the following
> errors:
> >
> > > > > ...../protobuf-2.3.0/examples$ make
> > > > > pkg-config --cflags protobuf  # fails if protobuf is not installed
> > > > > -pthread -I/usr/local/include
> > > > > c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config
> --
> > > > > cflags --libs protobuf`
> > > > > In file included from add_person.cc:6:
> > > > > addressbook.pb.h:9:42: error: google/protobuf/stubs/common.h: No
> such
> > > > > file or directory
> > > > > addressbook.pb.h:12:2: error: #error This file was generated by a
> > > > > newer version of protoc which is
> > > > > addressbook.pb.h:13:2: error: #error incompatible with your
> Protocol
> > > > > Buffer headers. Please update
> > > > > addressbook.pb.h:14:2: error: #error your headers.
> > > > > addressbook.pb.h:22:52: error: google/protobuf/
> > > > > generated_message_util.h: No such file or directory
> > > > > ......(many more)
> >
> > > > > My questions are:
> > > > > 1. Why it tells me that  protobuf is not installed?
> >
> > > > > 2. It keeps failing in finding google/protobuf/.... files. Why does
> > > > > this happen?
> >
> > > > > Thanks a lot
> >
> > > > > Zhang Bo
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> Groups
> > > > > "Protocol Buffers" group.
> > > > > To post to this group, send email to proto...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> <protobuf%2bunsubscr...@googlegroups.c om>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/protobuf?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to