Linux下利用protoc命令生成protobuf的头文件和源文件,根据mesType.proto文件 【Linux|Linux下利用protoc命令生成protobuf的头文件和源文件,根据mesType.proto文件】protobuf的message文件为 msgType.proto 生成c++头文件和源文件的方式
protoc --cpp_out=./ ./msgType.proto
protoc 命令详解 protoc 貌似不支持绝对路径,这里
Usage: protoc [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
-IPATH, --proto_path=PATHSpecify the directory in which to search for
imports.May be specified multiple times;
directories will be searched in order.If not
given, the current working directory is used.
--versionShow version info and exit.
-h, --helpShow this text and exit.
--encode=MESSAGE_TYPERead a text-format message of the given type
from standard input and write it in binary
to standard output.The message type must
be defined in PROTO_FILES or their imports.
--decode=MESSAGE_TYPERead a binary message of the given type from
standard input and write it in text format
to standard output.The message type must
be defined in PROTO_FILES or their imports.
--decode_rawRead an arbitrary protocol message from
standard input and write the raw tag/value
pairs in text format to standard output.No
PROTO_FILES should be given when using this
flag.
--descriptor_set_in=FILESSpecifies a delimited list of FILES
each containing a FileDescriptorSet (a
protocol buffer defined in descriptor.proto).
The FileDescriptor for each of the PROTO_FILES
provided will be loaded from these
FileDescriptorSets. If a FileDescriptor
appears multiple times, the first occurrence
will be used.
-oFILE,Writes a FileDescriptorSet (a protocol buffer,
--descriptor_set_out=FILE defined in descriptor.proto) containing all of
the input files to FILE.
--include_importsWhen using --descriptor_set_out, also include
all dependencies of the input files in the
set, so that the set is self-contained.
--include_source_infoWhen using --descriptor_set_out, do not strip
SourceCodeInfo from the FileDescriptorProto.
This results in vastly larger descriptors that
include information about the original
location of each decl in the source file as
well as surrounding comments.
--dependency_out=FILEWrite a dependency output file in the format
expected by make. This writes the transitive
set of input file paths to FILE
--error_format=FORMATSet the format in which to print errors.
FORMAT may be 'gcc' (the default) or 'msvs'
(Microsoft Visual Studio format).
--print_free_field_numbersPrint the free field numbers of the messages
defined in the given proto files. Groups share
the same field number space with the parent
message. Extension ranges are counted as
occupied fields numbers.--plugin=EXECUTABLESpecifies a plugin executable to use.
Normally, protoc searches the PATH for
plugins, but you may specify additional
executables not in the path using this flag.
Additionally, EXECUTABLE may be of the form
NAME=PATH, in which case the given plugin name
is mapped to the given executable even if
the executable's own name differs.
--cpp_out=OUT_DIRGenerate C++ header and source.
--csharp_out=OUT_DIRGenerate C# source file.
--java_out=OUT_DIRGenerate Java source file.
--javanano_out=OUT_DIRGenerate Java Nano source file.
--js_out=OUT_DIRGenerate JavaScript source.
--objc_out=OUT_DIRGenerate Objective C header and source.
--php_out=OUT_DIRGenerate PHP source file.
--python_out=OUT_DIRGenerate Python source file.
--ruby_out=OUT_DIRGenerate Ruby source file.
@Read options and filenames from file. If a
relative file path is specified, the file
will be searched in the working directory.
The --proto_path option will not affect how
this argument file is searched. Content of
the file will be expanded in the position of
@ as in the argument list. Note
that shell expansion is not applied to the
content of the file (i.e., you cannot use
quotes, wildcards, escapes, commands, etc.).
Each line corresponds to a single argument,
even if it contains spaces.
推荐阅读
- Linux|109 个实用 shell 脚本
- linux笔记|linux 常用命令汇总(面向面试)
- Linux|Linux--网络基础
- linux|apt update和apt upgrade命令 - 有什么区别()
- linux|2022年云原生趋势
- Go|Docker后端部署详解(Go+Nginx)
- 开源生态|GPL、MIT、Apache...开发者如何选择开源协议(一文讲清根本区别)
- GitHub|7 款可替代 top 命令的工具