Old title: How to compile nanopb/examples/simple/simple.proto file into simple.h and simple.c using nanopb and protobuf
Regarding this library: https://github.com/nanopb/nanopb
My goal is to follow this tutorial: https://jpa.kapsi.fi/nanopb/docs/concepts.html to convert nanopb/examples/simple/simple.proto into a .h and .c source file. I need simple instructions to do this on Ubuntu. I've been attempting it for days and am unable to get it to work.
The commands the tutorial says to do are:
protoc -omessage.pb message.proto
python ../generator/nanopb_generator.py message.pb
I cloned the nanopb repo, cd'ed into nanopb/examples/simple, and then substituting in simple.proto
instead of message.proto
in the commands above, I ran the following:
protoc -osimple.pb simple.proto
It worked fine, producing a simple.pb file.
The 2nd part, however, fails. When running from inside the nanopb/examples/simple folder, I get:
$ python ../../generator/nanopb_generator.py simple.pb
********************************************************************
*** Failed to import the protocol definitions for generator. ***
*** You have to run 'make' in the nanopb/generator/proto folder. ***
********************************************************************
Traceback (most recent call last):
File "../../generator/nanopb_generator.py", line 39, in <module>
import proto.nanopb_pb2 as nanopb_pb2
File "/home/gabriels/GS/dev/Protocol_Buffers/Nanopb/source/nanopb/generator/proto/nanopb_pb2.py", line 11, in <module>
from google.protobuf import symbol_database as _symbol_database
ImportError: cannot import name symbol_database
Running make
does nothing (says it's already done):
nanopb/generator/proto $ make
make: Nothing to be done for `all'.
Note that I am running the latest version of protoc
, built from the Google protobuf repo from source: https://github.com/protocolbuffers/protobuf.
I have also sought help from nanopb here, but am unable to figure it out, and feel like there's something basic here I'm missing because I just don't know enough: https://github.com/nanopb/nanopb/issues/417. Feels like I'm beating my head into the wall on something that should be simple and has already been done by at least 1448+ people before me (the number of stars on nanopb).