下了protoc但是不知道参数怎么用。现在把各个选项翻译下:
-IPATH, --proto_path=PATH:
Specify the directory in which to search forimports. May be specified multiple times;directories will be searched in order. If notgiven, the current working directory is used
指定输入的搜索目录。可以指定多次,为了将搜索目录。如果如果不存在就使用当前的工作目录。
--version
Show version info and exit.
显示版本信息并退出。
-h, --help
Show this text and exit.
显示帮助并退出。
--encode=MESSAGE_TYPE
Read 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.
从标准输入中读取一个给定类型的文本格式,并把它写在二进制输出到标准输出。消息类型必须定义在PROTO_FILES或他们的入口。
--decode_raw
Read 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.
消息从标准输入读取任意协议文本格式输出到标准输出和写入原始标记/值对。使用此标志时,应给予无PROTO_FILES。
-oFILE,
--descriptor_set_out=FILE
Writes a FileDescriptorSet (a protocol buffer, defined in descriptor.proto) containing all of the input files to FILE.
写入FileDescriptorSet(协议缓冲区,定义descriptor.proto)包含了所有输入文件文件。
--include_imports
When using --descriptor_set_out, also include all dependencies of the input files in the set, so that the set is self-contained.
当使用 - descriptor_set_out,还包括所有的输入文件集的依赖关系,使设定自足。
--include_source_info
When 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.
当使用 - descriptor_set_out,不从FileDescriptorProto剥离SourceCodeInfo。这样的结果DECL每个源文件中的原始位置以及周围的注释信息的描述符包括大得多。
--error_format=FORMAT
Set the format in which to print errors.FORMAT may be 'gcc' (the default) or 'msvs'(Microsoft Visual Studio format).
设置格式打印错误的格式.格式可能是“gcc”(默认)或者"msvs“(微软Visual Studio的格式)。
--plugin=EXECUTABLE
Specifies a plugin executable to use.Normally, protoc searches the PATH for plugins, but you may specify additionalexecutables not in the path using this flag.Additionally, EXECUTABLE may be of the formNAME=PATH, in which case the given plugin name is mapped to the given executable even if the executable's own name differs.
指定使用一个可执行插件。通常情况下,protoc 为插件搜索PATH路径,但你可以使用这个便令指定额外的可执行文件的路径。此外,可执行文件可以是从PATH搜索,在这种情况下,给定的插件name是映射到甚至写明可执行自己的名字不同的可执行文件。
--cpp_out=OUT_DIR
Generate C++ header and source.
生成c++头文件和源文件
--java_out=OUT_DIR
Generate Java source file.
生成java头文件和源文件
--python_out=OUT_DIR
Generate Python source file.
生成python源文件。
一个实例:
C:\Users\Gis_Kook>protoc --proto_path=C:\\Users\\Gis_Kook\\Desktop\\shot --cpp_out=F:\\OpenSource\\protobuf\\test C:\\Users\\Gis_Kook\\Desktop\\shot\\test.proto
比较变态的一点是必须制定--proto_path 而且其值必须在PATH环境变量里!
linux: protoc --cpp_out=./ *.proto
在 linux上依赖-lprotobuf