0

I have a protoBuff3 specification which looks something like

message MSG {
   string name = 1;
   repeated string data = 2;
}

And a options file that sets "MSG.data max_count:20"

I am trying to encode and decode protobuffs without using .

I am currently using pb_ostream_from_buffer and pb_encode however I when trying to link i get an error saying pb_ostream_..., pb_encode, pb_decode,... external symbols do not exist. I am able to find these functions defined in pb_encode.h and pb_decode.h

.Online i see reference to functions like ParseFromString and SerializeToString, however I can not find these function anywhere.

What is the proper way to serialize and serialize my message without iostreams?

4

1 回答 1

1

有许多彼此独立的 protobuf 库。通常你会选择一个并使用它:

这些中的任何一个都可用于序列化和解析来自内存缓冲区的消息。此外,Google 的库支持 C++ iostream,而 nanopb 支持用 C 实现的类似流系统。

关于“外部符号不存在”的错误表明您没有链接到 nanopb 库代码(pb_encode.cpb_decode.cpb_common.c。像往常一样,.h文件只包含函数声明,而您需要链接.c文件以提供函数定义

于 2018-10-10T07:59:46.167 回答