mac下Protobuf的安装与使用

1. 安装

protobuf的github主页:https://github.com/protocolbuffers/protobuf

release页面的tag标签下。找到对应的protobuf版本。

下载下来后进入解压包目录下

  1. ./configure

  2. 直接make

  3. make check

  4. sudo make install

  5. protoc --version测试是否安装成功

2. 使用

首先,我们创建一个简单的proto文件

syntax = "proto3";

message BookInfo {
   int64 id = 1;
   string title = 2;
   string author = 3;
}

然后使用如下命令生成python代码

protoc --ptrhon_out=. foo.proto

待续

 

参考链接:

1. https://www.cnblogs.com/pengpp/p/11364531.html

2. https://github.com/apple/swift-protobuf/

原编辑时间 2021-02-03 15:24

posted @ 2021-11-24 14:43  Rogn  阅读(480)  评论(0编辑  收藏  举报