[protobuf] Re: dynamic generation of proto objects and the error: Assignment not allowed to composite field
One other thing I am now trying is to take the task_instance object and call SerializeToString() on it, then use task_info_instance.MergeFromString(serialized_task_instance) this is not raising any exception and does seem to be setting the field, but I'm not entirely convinced yet On Friday, March 3, 2017 at 1:09:09 PM UTC-8, Tom Lichtenberg wrote: > > I’m trying to dynamically create objects from discovery of pb2 generated > protobuf files and assign appropriate values to their fields. If the field > types are simple, this is straightforward - e.g. for TYPE_BOOL, > setattr(obj, “field_name”, True) works fine - but if the field is > TYPE_MESSAGE, making an instance of that field and using setattr(obj, > “field_name”, instance) results in an error: > Assignment not allowed to composite field "task" in protocol message > object. > from python2.7/site-packages/google/protobuf/internal/python_message.py", > line 736, in setter > > > sample code: dummy/test_dummy.proto > > > syntax = "proto3"; > > message task { >int32 id = 1; >string msg = 2; > } > > message task_info { >task task = 1; > } > > > from this I used protoc to generate a test_dummy_pb2.py > > For example, I want to create a task_info object, so by exploring the > imported pb2 module, I find the task_info descriptor and create an instance > of it. I see that its field ‘task’ is of TYPE_MESSAGE so I create an > instance of that as well and call setattr(task_instance, “id”, 1) and > setattr(task_instance, “msg”, “some message”) to populate it, and then go > back and call setattr(task_info_instance, “task”, task_instance). Here I > get the error: Assignment not allowed to composite field "task" in > protocol message object. > > > programatically I can import this module and assign values well enough, > for example in the python shell: > >> import importlib > >> oobj = importlib.import_module("dummy.dummy.test_dummy_pb2", > package=None) > >> obj = getattr(oobj, "task_info") > >> task_info_instance = obj() > >> task_info_instance.task.id = 1 > >> task_info_instance.task.msg = "some message" > >> print task_info_instance > > task { > id: 1 > msg: "some message" > } > > > But dynamically I can’t explicitly assign it like that. I would need > something like a setattr() function that can set an object’s composite > object field. I’m hoping that someone can shed some light on this for me. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] dynamic generation of proto objects and the error: Assignment not allowed to composite field
I’m trying to dynamically create objects from discovery of pb2 generated protobuf files and assign appropriate values to their fields. If the field types are simple, this is straightforward - e.g. for TYPE_BOOL, setattr(obj, “field_name”, True) works fine - but if the field is TYPE_MESSAGE, making an instance of that field and using setattr(obj, “field_name”, instance) results in an error: Assignment not allowed to composite field "task" in protocol message object. from python2.7/site-packages/google/protobuf/internal/python_message.py", line 736, in setter sample code: dummy/test_dummy.proto syntax = "proto3"; message task { int32 id = 1; string msg = 2; } message task_info { task task = 1; } from this I used protoc to generate a test_dummy_pb2.py For example, I want to create a task_info object, so by exploring the imported pb2 module, I find the task_info descriptor and create an instance of it. I see that its field ‘task’ is of TYPE_MESSAGE so I create an instance of that as well and call setattr(task_instance, “id”, 1) and setattr(task_instance, “msg”, “some message”) to populate it, and then go back and call setattr(task_info_instance, “task”, task_instance). Here I get the error: Assignment not allowed to composite field "task" in protocol message object. programatically I can import this module and assign values well enough, for example in the python shell: >> import importlib >> oobj = importlib.import_module("dummy.dummy.test_dummy_pb2", package=None) >> obj = getattr(oobj, "task_info") >> task_info_instance = obj() >> task_info_instance.task.id = 1 >> task_info_instance.task.msg = "some message" >> print task_info_instance task { id: 1 msg: "some message" } But dynamically I can’t explicitly assign it like that. I would need something like a setattr() function that can set an object’s composite object field. I’m hoping that someone can shed some light on this for me. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
Re: [protobuf] OpenBSD 6.0 make check fails/core dumped
On Friday, March 3, 2017 at 4:57:39 PM UTC+1, Rolf Sommerhalder wrote: > > However, my attempts with v3.1.0 fail as it had not the patch for OpenBSD > yet, and make of v3.2.0 as well as of Master fail quite early, as follows: > Sorry, I have posted the wrong output, e.g. the error which make throws when the patch for OpenBSD is missing. Here is the correct output: ... depbase=`echo google/protobuf/io/coded_stream.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/coded_stream.lo -MD -MP -MF $depbase.Tpo -c -o google/protobuf/io/coded_stream.lo google/protobuf/io/coded_stream.cc && mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/coded_stream.lo -MD -MP -MF google/protobuf/io/.deps/coded_stream.Tpo -c google/protobuf/io/coded_stream.cc -fPIC -DPIC -o google/protobuf/io/.libs/coded_stream.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/coded_stream.lo -MD -MP -MF google/protobuf/io/.deps/coded_stream.Tpo -c google/protobuf/io/coded_stream.cc -o google/protobuf/io/coded_stream.o >/dev/null 2>&1 depbase=`echo google/protobuf/io/zero_copy_stream.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/zero_copy_stream.lo -MD -MP -MF $depbase.Tpo -c -o google/protobuf/io/zero_copy_stream.lo google/protobuf/io/zero_copy_stream.cc && mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/zero_copy_stream.lo -MD -MP -MF google/protobuf/io/.deps/zero_copy_stream.Tpo -c google/protobuf/io/zero_copy_stream.cc -fPIC -DPIC -o google/protobuf/io/.libs/zero_copy_stream.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/zero_copy_stream.lo -MD -MP -MF google/protobuf/io/.deps/zero_copy_stream.Tpo -c google/protobuf/io/zero_copy_stream.cc -o google/protobuf/io/zero_copy_stream.o >/dev/null 2>&1 depbase=`echo google/protobuf/io/zero_copy_stream_impl_lite.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/zero_copy_stream_impl_lite.lo -MD -MP -MF $depbase.Tpo -c -o google/protobuf/io/zero_copy_stream_impl_lite.lo google/protobuf/io/zero_copy_stream_impl_lite.cc && mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/zero_copy_stream_impl_lite.lo -MD -MP -MF google/protobuf/io/.deps/zero_copy_stream_impl_lite.Tpo -c google/protobuf/io/zero_copy_stream_impl_lite.cc -fPIC -DPIC -o google/protobuf/io/.libs/zero_copy_stream_impl_lite.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/io/zero_copy_stream_impl_lite.lo -MD -MP -MF google/protobuf/io/.deps/zero_copy_stream_impl_lite.Tpo -c google/protobuf/io/zero_copy_stream_impl_lite.cc -o google/protobuf/io/zero_copy_stream_impl_lite.o >/dev/null 2>&1 depbase=`echo google/protobuf/any.pb.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/any.pb.lo -MD -MP -MF $depbase.Tpo -c -o google/protobuf/any.pb.lo google/protobuf/any.pb.cc && mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/any.pb.lo -MD -MP -MF google/protobuf/.deps/any.pb.Tpo -c google/protobuf/any.pb.cc -fPIC -DPIC -o google/protobuf/.libs/any.pb.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/any.pb.lo -MD -MP -MF google/protobuf/.deps/any.pb.Tpo -c google/protobuf/any.pb.cc -o google/protobuf/any.pb.o >/dev/null 2>&1 depbase=`echo google/protobuf/api.pb.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g
Re: [protobuf] OpenBSD 6.0 make check fails/core dumped
Hello, In the meantime, did anyone manage to build Protobuf3 on OpenBSD 6.0 amd64, or -current? I have tried to build Protobuf v3.1.0, v3.2.0, as well as Master branch on OpenBSD 6.(more-or-less current) amd64, using autoconf-2.69p2, autogen-5.8.7p4, automake-1.15p0, libtool-2.4.2p0, and gcc v4.2.1 . However, my attempts with v3.1.0 fail as it had not the patch for OpenBSD yet, and make of v3.2.0 as well as of Master fail quite early, as follows: [rs@apuA:protobuf]$ make make all-recursive Making all in . Making all in src depbase=`echo google/protobuf/api.pb.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`; /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/api.pb.lo -MD -MP -MF $depbase.Tpo -c -o google/protobuf/api.pb.lo google/protobuf/api.pb.cc && mv -f $depbase.Tpo $depbase.Plo libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -O2 -g -DNDEBUG -MT google/protobuf/api.pb.lo -MD -MP -MF google/protobuf/.deps/api.pb.Tpo -c google/protobuf/api.pb.cc -fPIC -DPIC -o google/protobuf/.libs/api.pb.o ./google/protobuf/arena.h: In static member function 'static GenericType* google::protobuf::internal::GenericTypeHandler ::NewFromPrototype(const GenericType*, google::protobuf::Arena*) [with GenericType = google::protobuf::Mixin]': ./google/protobuf/arena.h:643: sorry, unimplemented: inlining failed in call to 'static T* google::protobuf::Arena::CreateMaybeMessage(google::protobuf::Arena*, ...) [with T =google::protobuf::Mixin]': function not inlinable ./google/protobuf/repeated_field.h:588: sorry, unimplemented: called from here *** Error 1 in src (Makefile:3968 'google/protobuf/api.pb.lo') *** Error 1 in . (Makefile:1414 'all-recursive') *** Error 1 in /home/rs/protobuf/protobuf (Makefile:1296 'all') [rs@apuA:protobuf]$ Under Ubuntu Linux, I did manage to build them, and they pass make check. How did you get v3.2.0 to build with eg++ under OpenBSD 6.0, so that you were able to run make check? Thank you, Rolf -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
[protobuf] Protobuf 3.2.0 + Qt 5.8 (Windows)
Hi everyone, I'm trying to build Protobuf with Minwg from MSYS2 as specified in documentation (C++ Installation - Windows). Everything goes perfect and all libraries are created. The problem comes trying to compile and test the "addressbook" sample in Qt/C++. After generating the .pb.cc and .pb.h, I add this to my .pro file inside my Qt project: *# Google Protocol Buffers libraryINCLUDEPATH += "C:\\protobuf\\install\\include"LIBS += -L"C:\\protobuf\\install\\lib" -llibprotobuf* A lot of "undefined reference" errors (almost 200 errors) are shown and I am not able to make it work: *C:\Qt Developments\MyProject\protoFolder\addressbook.pb.cc:86: error: undefined reference to `google::protobuf::internal::AssignDescriptors(std::string const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)'C:\Qt Developments\MyProject\protoFolder\addressbook.pb.cc:97: error: undefined reference to `google::protobuf::internal::RegisterAllTypes(google::protobuf::Metadata const*, int)'C:\Qt Developments\MyProject\protoFolder\addressbook.pb.cc:112: error: undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)'And so on...* Has anyone ever come across this error? Same proccess, same project, tested in a Fedora machine... it works like a charm! But I have to make it work on Windows :( Thanks in advance for your help. Mastic. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.