Re: [protobuf]
I've tried to build the project manually with the example makefile, the 2 executables works well. I believe that the linking option that makes the correct linking is `pkg-config --cflags --libs protobuf`.. now the question is.. how can i put them into Eclipse? but it's not a protobuf question anymore.. thanks! On 23 Giu, 18:44, Jason Hsueh wrote: > Yeah, it appears you aren't linking against the protobuf runtime. Did you > set up eclipse to build from the makefile in the examples directory? > > On Thu, Jun 23, 2011 at 8:46 AM, Enrico Viappiani wrote: > > > I've installed protobuf 2.4.1 on ubuntu, running configure,make, make > > check and make install, and everything seems fine. > > Then I've tried to compile the examples code in the packet, "make > > cpp" , I've obtained the .cc and .h from the .proto file. > > In Eclipse CDT, I've imported those 2 files, along with the other > > 2 .cc sources,list_people.cc and add_person.cc ; > > In the included libraries I've both /usr/local/include and /usr/local/ > > lib. > > But doesn't build at all because of tons of errors like this: > > > ... > > (google::protobuf::MessageLite const&)' > > ./addressbook.pb.o:(.rodata._ZTVN8tutorial18Person_PhoneNumberE[vtable > > for tutorial::Person_PhoneNumber]+0x88): undefined reference to > > `google::protobuf::Message::DiscardUnknownFields()' > > ./addressbook.pb.o:(.rodata._ZTVN8tutorial18Person_PhoneNumberE[vtable > > for tutorial::Person_PhoneNumber]+0x90): undefined reference to > > `google::protobuf::Message::SpaceUsed() const' > > ./addressbook.pb.o:(.rodata._ZTIN8tutorial11AddressBookE[typeinfo for > > tutorial::AddressBook]+0x10): undefined reference to `typeinfo for > > google::protobuf::Message' > > ./addressbook.pb.o:(.rodata._ZTIN8tutorial6PersonE[typeinfo for > > tutorial::Person]+0x10): undefined reference to `typeinfo for > > google::protobuf::Message' > > ./addressbook.pb.o: > > (.rodata._ZTIN8tutorial18Person_PhoneNumberE[typeinfo for > > tutorial::Person_PhoneNumber]+0x10): undefined reference to `typeinfo > > for google::protobuf::Message' > > ./list_people.o: In function `main': > > list_people.cc:(.text+0x1ed): undefined reference to > > `google::protobuf::internal::VerifyVersion(int, int, char const*)' > > list_people.cc:(.text+0x297): undefined reference to > > `google::protobuf::Message::ParseFromIstream(std::basic_istream > std::char_traits >*)' > > list_people.cc:(.text+0x313): undefined reference to > > `google::protobuf::ShutdownProtobufLibrary()' > > .. > > > even on the macro GOOGLE_VERIFY_VERSION i get "undefined reference to > > `google::protobuf::internal::VerifyVersion(int, int, char const*)' " > > > I believe that is a linking problem, but I'm not sure.. > > > I'm really confused.. and I don't know really how to check my > > installation.. > > > some Ideas? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Protocol Buffers" group. > > To post to this group, send email to protobuf@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. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
[protobuf] Re: Read multiple protobufs from single file
Kind of what I suspected. Alright, thanks! On Jun 23, 12:41 pm, Jason Hsueh wrote: > There's not enough information: > seehttp://code.google.com/apis/protocolbuffers/docs/techniques.html#stre... > > > > > > > > On Thu, Jun 23, 2011 at 8:55 AM, mjs483 wrote: > > Hi, > > > Is there any way to read a protobuf from a file input stream without > > consuming the entire file? Say for example if the file contains more > > than just one protobuf? > > > I'd like to archive a stream of protobufs to a file for later analysis > > by simply writing them one after another to a single file with > > SerializeToOstream(&output) in C++. However according to the > > documentation, ParseFromIstream(&input) will always consume the entire > > file. Is there any way around this? Or is there not enough information > > in the encoded protobuf for this to be possible? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Protocol Buffers" group. > > To post to this group, send email to protobuf@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. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
Re: [protobuf]
Yeah, it appears you aren't linking against the protobuf runtime. Did you set up eclipse to build from the makefile in the examples directory? On Thu, Jun 23, 2011 at 8:46 AM, Enrico Viappiani wrote: > I've installed protobuf 2.4.1 on ubuntu, running configure,make, make > check and make install, and everything seems fine. > Then I've tried to compile the examples code in the packet, "make > cpp" , I've obtained the .cc and .h from the .proto file. > In Eclipse CDT, I've imported those 2 files, along with the other > 2 .cc sources,list_people.cc and add_person.cc ; > In the included libraries I've both /usr/local/include and /usr/local/ > lib. > But doesn't build at all because of tons of errors like this: > > ... > (google::protobuf::MessageLite const&)' > ./addressbook.pb.o:(.rodata._ZTVN8tutorial18Person_PhoneNumberE[vtable > for tutorial::Person_PhoneNumber]+0x88): undefined reference to > `google::protobuf::Message::DiscardUnknownFields()' > ./addressbook.pb.o:(.rodata._ZTVN8tutorial18Person_PhoneNumberE[vtable > for tutorial::Person_PhoneNumber]+0x90): undefined reference to > `google::protobuf::Message::SpaceUsed() const' > ./addressbook.pb.o:(.rodata._ZTIN8tutorial11AddressBookE[typeinfo for > tutorial::AddressBook]+0x10): undefined reference to `typeinfo for > google::protobuf::Message' > ./addressbook.pb.o:(.rodata._ZTIN8tutorial6PersonE[typeinfo for > tutorial::Person]+0x10): undefined reference to `typeinfo for > google::protobuf::Message' > ./addressbook.pb.o: > (.rodata._ZTIN8tutorial18Person_PhoneNumberE[typeinfo for > tutorial::Person_PhoneNumber]+0x10): undefined reference to `typeinfo > for google::protobuf::Message' > ./list_people.o: In function `main': > list_people.cc:(.text+0x1ed): undefined reference to > `google::protobuf::internal::VerifyVersion(int, int, char const*)' > list_people.cc:(.text+0x297): undefined reference to > `google::protobuf::Message::ParseFromIstream(std::basic_istream std::char_traits >*)' > list_people.cc:(.text+0x313): undefined reference to > `google::protobuf::ShutdownProtobufLibrary()' > .. > > even on the macro GOOGLE_VERIFY_VERSION i get "undefined reference to > `google::protobuf::internal::VerifyVersion(int, int, char const*)' " > > I believe that is a linking problem, but I'm not sure.. > > I'm really confused.. and I don't know really how to check my > installation.. > > some Ideas? > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to protobuf@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. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
Re: [protobuf] Read multiple protobufs from single file
There's not enough information: see http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming On Thu, Jun 23, 2011 at 8:55 AM, mjs483 wrote: > Hi, > > Is there any way to read a protobuf from a file input stream without > consuming the entire file? Say for example if the file contains more > than just one protobuf? > > I'd like to archive a stream of protobufs to a file for later analysis > by simply writing them one after another to a single file with > SerializeToOstream(&output) in C++. However according to the > documentation, ParseFromIstream(&input) will always consume the entire > file. Is there any way around this? Or is there not enough information > in the encoded protobuf for this to be possible? > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to protobuf@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. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
[protobuf] Read multiple protobufs from single file
Hi, Is there any way to read a protobuf from a file input stream without consuming the entire file? Say for example if the file contains more than just one protobuf? I'd like to archive a stream of protobufs to a file for later analysis by simply writing them one after another to a single file with SerializeToOstream(&output) in C++. However according to the documentation, ParseFromIstream(&input) will always consume the entire file. Is there any way around this? Or is there not enough information in the encoded protobuf for this to be possible? -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
[protobuf]
I've installed protobuf 2.4.1 on ubuntu, running configure,make, make check and make install, and everything seems fine. Then I've tried to compile the examples code in the packet, "make cpp" , I've obtained the .cc and .h from the .proto file. In Eclipse CDT, I've imported those 2 files, along with the other 2 .cc sources,list_people.cc and add_person.cc ; In the included libraries I've both /usr/local/include and /usr/local/ lib. But doesn't build at all because of tons of errors like this: ... (google::protobuf::MessageLite const&)' ./addressbook.pb.o:(.rodata._ZTVN8tutorial18Person_PhoneNumberE[vtable for tutorial::Person_PhoneNumber]+0x88): undefined reference to `google::protobuf::Message::DiscardUnknownFields()' ./addressbook.pb.o:(.rodata._ZTVN8tutorial18Person_PhoneNumberE[vtable for tutorial::Person_PhoneNumber]+0x90): undefined reference to `google::protobuf::Message::SpaceUsed() const' ./addressbook.pb.o:(.rodata._ZTIN8tutorial11AddressBookE[typeinfo for tutorial::AddressBook]+0x10): undefined reference to `typeinfo for google::protobuf::Message' ./addressbook.pb.o:(.rodata._ZTIN8tutorial6PersonE[typeinfo for tutorial::Person]+0x10): undefined reference to `typeinfo for google::protobuf::Message' ./addressbook.pb.o: (.rodata._ZTIN8tutorial18Person_PhoneNumberE[typeinfo for tutorial::Person_PhoneNumber]+0x10): undefined reference to `typeinfo for google::protobuf::Message' ./list_people.o: In function `main': list_people.cc:(.text+0x1ed): undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' list_people.cc:(.text+0x297): undefined reference to `google::protobuf::Message::ParseFromIstream(std::basic_istream >*)' list_people.cc:(.text+0x313): undefined reference to `google::protobuf::ShutdownProtobufLibrary()' .. even on the macro GOOGLE_VERIFY_VERSION i get "undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' " I believe that is a linking problem, but I'm not sure.. I'm really confused.. and I don't know really how to check my installation.. some Ideas? -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
Re: [protobuf] Re: Self describing messages
Oh, I missed that you were reading the FileDescriptorSet from a separate file, not the same stream. This isn't exactly "self describing" since when you transmit the message you assume the recipient knows what type the message is, and has access to the FileDescriptorSet. See http://code.google.com/apis/protocolbuffers/docs/techniques.html#self-description On Thu, Jun 23, 2011 at 12:31 AM, slookin wrote: > Thanks Jason, > It is all my code (link to real java class - > http://test.look-in.net/pf/pf.zip. > Could you give me links with examples or explain why i should > "serializes the FileDescriptorSet"? > > On Jun 22, 8:35 pm, Jason Hsueh wrote: > > On Wed, Jun 22, 2011 at 3:30 AM, slookin wrote: > > > I trying to develop "flexible" server for reciving message, i'm not > > > able to create java classes for each message type, but I can upload > > > proto descripter on server. Of course client (sender) will use > > > generated java classes for prepare messages: > > > > > My code (sender): > > > Person.Builder person = Person.newBuilder(); > > > person.setId(Integer.valueOf(42)); > > > person.setEmail("test_em...@gmail.com"); > > > person.setName("Viktor Villari"); > > > Person p=person.build(); > > > FileOutputStream fstream = new FileOutputStream ("message.pf"); > > > CodedOutputStream outSream = CodedOutputStream.newInstance(fstream); > > > p.writeTo(outSream); > > > outSream.flush(); > > > System.out.println("sent"); > > > > > Reciver (address.descriptor.proto - grenerated via descriptor.proto): > > >FileInputStream input = new FileInputStream > > > ("address.descriptor.proto"); > > >DescriptorProtos.FileDescriptorSet > > > fdsProto=DescriptorProtos.FileDescriptorSet.parseFrom(input); > > >input = new FileInputStream ("message.pf"); > > >// > > > System.out.println(fds.getFile(0).getMessageType(0).getName()); > > >System.out.println("File name = > > > "+fdsProto.getFile(0).getName()); > > >// System.out.println("Message type = > > > "+fdsProto.getFile(0).getMessageType(0).getName()); > > >// System.out.println("Field info = > > > "+fdsProto.getFile(0).getMessageType(0).getField(0).getName()+" > > > "+fdsProto.getFile(0).getMessageType(0).getField(0).getType()); > > >FileDescriptor > > > fileDescr=FileDescriptor.buildFrom(fdsProto.getFile(0), new > > > FileDescriptor[0]); > > >System.out.println("Message type = > > > "+fileDescr.getMessageTypes().get(0).getName()); > > >System.out.println("Field info = > > > "+fileDescr.getMessageTypes().get(0).getFields().get(0).getName()+" > > > type= > > > "+fileDescr.getMessageTypes().get(0).getFields().get(0).getType()); > > >DynamicMessage > > > dm=DynamicMessage.parseFrom(fdsProto.getDescriptor(), > > > input); > > > > On this line, you are passing the descriptor for the FileDescriptorSet. > You > > should be using fileDescr to get at the Person message type. (Note that > your > > description scheme does not indicate what message type is actually used. > But > > I also don't see the code snippet that serializes the FileDescriptorSet, > or > > for that matter delimit between the FileDescriptorSet and the serialized > > Person data, so maybe you are doing something elsewhere) > > > > > > > > > > > > > > > > >System.out.println("DynamicMessage to string > > > \n"+dm.toString()); > > >// problem line > > >System.out.println("Person.name = "+ > > > dm.getField(fileDescr.getMessageTypes().get(0).getFields().get(0))); > > >// > > > > > Output: > > > File name = addressbook.proto > > > Message type = Person > > > Field info = name type= STRING > > > DynamicMessage to string > > > 2: "Viktor Villari" > > > 3: 42 > > > 4: "test_em...@gmail.com" > > > > > Exception in thread "main" java.lang.IllegalArgumentException: > > > FieldDescriptor does not match message type. > > >at > > > > > > com.google.protobuf.DynamicMessage.verifyContainingType(DynamicMessage.java: > > > 242) > > >at > com.google.protobuf.DynamicMessage.getField(DynamicMessage.java: > > > 160) > > >at net.lookin.protobuf.Test.main(Test.java:64) > > > > > Why I recive exception? > > > How I can access to specific field value in DynamicMessage? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Protocol Buffers" group. > > > To post to this group, send email to protobuf@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. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to protobuf@googlegroups.com. > To unsubscribe from this group, send email to > proto
[protobuf] Re: Issue 305 in protobuf: CodedInputStream constructors missing.
Comment #1 on issue 305 by roxsan.p...@videotron.ca: CodedInputStream constructors missing. http://code.google.com/p/protobuf/issues/detail?id=305 Close this issue, the constructor has been inlined in the .h - makefile error including previous version ... -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
[protobuf] Issue 305 in protobuf: CodedInputStream constructors missing.
Status: New Owner: liuj...@google.com Labels: Type-Defect Priority-Medium New issue 305 by roxsan.p...@videotron.ca: CodedInputStream constructors missing. http://code.google.com/p/protobuf/issues/detail?id=305 We just upgraded to protobuf 2.4.1 from 2.2 and get the followin linking error: undefined reference to 'google::protobuf::io::CodedInputStream::CodedInputStream(unsigned char const*, int)' The symbol is definitely missing from the library. We looked at the .h file and the declaration is fine, but couldn't find the definition in the .cc file - so it is definitely missing from the distribution! -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.
[protobuf] Re: Self describing messages
Thanks Jason, It is all my code (link to real java class - http://test.look-in.net/pf/pf.zip. Could you give me links with examples or explain why i should "serializes the FileDescriptorSet"? On Jun 22, 8:35 pm, Jason Hsueh wrote: > On Wed, Jun 22, 2011 at 3:30 AM, slookin wrote: > > I trying to develop "flexible" server for reciving message, i'm not > > able to create java classes for each message type, but I can upload > > proto descripter on server. Of course client (sender) will use > > generated java classes for prepare messages: > > > My code (sender): > > Person.Builder person = Person.newBuilder(); > > person.setId(Integer.valueOf(42)); > > person.setEmail("test_em...@gmail.com"); > > person.setName("Viktor Villari"); > > Person p=person.build(); > > FileOutputStream fstream = new FileOutputStream ("message.pf"); > > CodedOutputStream outSream = CodedOutputStream.newInstance(fstream); > > p.writeTo(outSream); > > outSream.flush(); > > System.out.println("sent"); > > > Reciver (address.descriptor.proto - grenerated via descriptor.proto): > > FileInputStream input = new FileInputStream > > ("address.descriptor.proto"); > > DescriptorProtos.FileDescriptorSet > > fdsProto=DescriptorProtos.FileDescriptorSet.parseFrom(input); > > input = new FileInputStream ("message.pf"); > > // > > System.out.println(fds.getFile(0).getMessageType(0).getName()); > > System.out.println("File name = > > "+fdsProto.getFile(0).getName()); > > // System.out.println("Message type = > > "+fdsProto.getFile(0).getMessageType(0).getName()); > > // System.out.println("Field info = > > "+fdsProto.getFile(0).getMessageType(0).getField(0).getName()+" > > "+fdsProto.getFile(0).getMessageType(0).getField(0).getType()); > > FileDescriptor > > fileDescr=FileDescriptor.buildFrom(fdsProto.getFile(0), new > > FileDescriptor[0]); > > System.out.println("Message type = > > "+fileDescr.getMessageTypes().get(0).getName()); > > System.out.println("Field info = > > "+fileDescr.getMessageTypes().get(0).getFields().get(0).getName()+" > > type= > > "+fileDescr.getMessageTypes().get(0).getFields().get(0).getType()); > > DynamicMessage > > dm=DynamicMessage.parseFrom(fdsProto.getDescriptor(), > > input); > > On this line, you are passing the descriptor for the FileDescriptorSet. You > should be using fileDescr to get at the Person message type. (Note that your > description scheme does not indicate what message type is actually used. But > I also don't see the code snippet that serializes the FileDescriptorSet, or > for that matter delimit between the FileDescriptorSet and the serialized > Person data, so maybe you are doing something elsewhere) > > > > > > > > > System.out.println("DynamicMessage to string > > \n"+dm.toString()); > > // problem line > > System.out.println("Person.name = "+ > > dm.getField(fileDescr.getMessageTypes().get(0).getFields().get(0))); > > // > > > Output: > > File name = addressbook.proto > > Message type = Person > > Field info = name type= STRING > > DynamicMessage to string > > 2: "Viktor Villari" > > 3: 42 > > 4: "test_em...@gmail.com" > > > Exception in thread "main" java.lang.IllegalArgumentException: > > FieldDescriptor does not match message type. > > at > > > com.google.protobuf.DynamicMessage.verifyContainingType(DynamicMessage.java: > > 242) > > at com.google.protobuf.DynamicMessage.getField(DynamicMessage.java: > > 160) > > at net.lookin.protobuf.Test.main(Test.java:64) > > > Why I recive exception? > > How I can access to specific field value in DynamicMessage? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Protocol Buffers" group. > > To post to this group, send email to protobuf@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. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@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.