protobuf编译
关于protobuf的安装可以参考[linux]protoc的安装
将.proto文件编译为.ph.h和.pb.cc文件
编译命令:
protoc --proto_path=src --cpp_out=build/gen src/foo.proto src/bar/baz.proto
编译器会读取
src/foo.proto
src/bar/baz.proto
生成
build/gen/foo.pb.h
build/gen/foo.pb.h
build/gen/bar/baz.pb.h
build/gen/bar/baz.pb.h
其中
build/gen/ba
r文件夹会自动创建
build/ build/gen
不会自动创建
以上内容翻译自官方文档
执行过后会发生以下变化
The names of the output files are computed by taking the name of the
.proto
file and making two changes:
- The extension (