google/protobuf/pyext/descriptor_containers.cc:69:45: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]

43 views
Skip to first unread message

ratankumar shivaratri

unread,
Oct 3, 2019, 3:26:50 PM10/3/19
to Protocol Buffers
Hi All,

Basically I am following the tutorial from the below link.

I have reached till the point where I have to run the below command.
"python3 setup.py build --cpp_implementation" 

I am using Raspberry pi 4 B model. Python version is 3.7
after running the command i have received the below error.

"
pi@raspberrypi:~/protobuf-3.5.1/python $ python3 setup.py build --cpp_implementation
running build
running build_py
running build_ext
building 'google.protobuf.pyext._message' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I../src -I/usr/include/python3.7m -c google/protobuf/pyext/descriptor_database.cc -o build/temp.linux-armv7l-3.7/google/protobuf/pyext/descriptor_database.o -Wno-write-strings -Wno-invalid-offsetof -Wno-sign-compare
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I../src -I/usr/include/python3.7m -c google/protobuf/pyext/repeated_composite_container.cc -o build/temp.linux-armv7l-3.7/google/protobuf/pyext/repeated_composite_container.o -Wno-write-strings -Wno-invalid-offsetof -Wno-sign-compare
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I../src -I/usr/include/python3.7m -c google/protobuf/pyext/descriptor_containers.cc -o build/temp.linux-armv7l-3.7/google/protobuf/pyext/descriptor_containers.o -Wno-write-strings -Wno-invalid-offsetof -Wno-sign-compare
google/protobuf/pyext/descriptor_containers.cc: In function ‘bool google::protobuf::python::descriptor::_GetItemByKey(google::protobuf::python::PyContainer*, PyObject*, const void**)’:
google/protobuf/pyext/descriptor_containers.cc:69:45: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
        ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
                      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
google/protobuf/pyext/descriptor_containers.cc:172:13: note: in expansion of macro ‘PyString_AsStringAndSize’
         if (PyString_AsStringAndSize(key, &name, &name_size) < 0) {
             ^~~~~~~~~~~~~~~~~~~~~~~~
google/protobuf/pyext/descriptor_containers.cc:69:45: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
        ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
                      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
google/protobuf/pyext/descriptor_containers.cc:189:13: note: in expansion of macro ‘PyString_AsStringAndSize’
         if (PyString_AsStringAndSize(key, &camelcase_name, &name_size) < 0) {
             ^~~~~~~~~~~~~~~~~~~~~~~~
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
"


Please suggest on how to resolve it. I followed the below options but it did not resolve.

sudo apt-get update
sudo apt-get install build-essential python-dev git scons swig
sudo apt-get install libzbar-dev libzbar0
sudo apt install python-dev
sudo apt-get install portaudio19-dev
sudo apt install -y python python-pip libffi-dev python-backports.ssl-match-hostname

Adam Cozzette

unread,
Oct 3, 2019, 7:38:00 PM10/3/19
to ratankumar shivaratri, Protocol Buffers
I believe that is due to an API change in Python 3.7 which was fixed in protobuf with this pull request: https://github.com/protocolbuffers/protobuf/pull/4862 If you use a more recent version of protobuf then that should fix the problem.

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/d0475b8e-691b-43fc-924c-587d3fe06631%40googlegroups.com.

ratankumar shivaratri

unread,
Oct 5, 2019, 2:04:11 AM10/5/19
to Protocol Buffers
Hi Adam,

Thanks for the suggestion. I have upgraded the protobuf version to 3.9.2 and the issue has been resolved. :)

Is there any option to mark this as resolved or solved or answered?
To unsubscribe from this group and stop receiving emails from it, send an email to prot...@googlegroups.com.

Adam Cozzette

unread,
Oct 7, 2019, 1:37:03 PM10/7/19
to ratankumar shivaratri, Protocol Buffers
Great, I'm glad the upgrade solved the problem. I don't think there is any way to mark the mailing list thread resolved so no need to worry about that.

To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/bc31bc2c-0e1e-4804-84bb-4a4d0995e959%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages