c++ protobuf错误:此文件由旧版本的协议生成

gfttwv5a  于 2023-01-18  发布在  其他
关注(0)|答案(1)|浏览(192)

我正试图开发一个程序来演示protobuf的使用。
程序包管理器:vcpkg公司
C标准:C20
微软Visual C++2022
安装日志

vcpkg.exe install protobuf
Computing installation plan...
The following packages are already installed:
    protobuf[core]:x64-windows -> 3.21.4
protobuf:x64-windows is already installed
Restored 0 package(s) from C:\Users\DarkSorrow\AppData\Local\vcpkg\archives in 409.1 us. Use --debug to see more details.

Total elapsed time: 130.8 ms

protobuf provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(protobuf CONFIG REQUIRED)
    target_link_libraries(main PRIVATE protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)

我收到了以下提到的错误。
错误:

fatal  error C1189: #error:  This file was generated by an older version of protoc which is

我没有写任何代码,只是在项目中包含了生成的文件。
代码生成:

protoc test.proto --cpp_out=.

代码(试验样品):

syntax = "proto3";
message Person {
  optional string name = 1;
  optional int32 id = 2;
  optional string email = 3;
}

方案缓冲区生成器版本

protoc --version
libprotoc 3.16.0
mklgxw1f

mklgxw1f1#

您必须执行:Protoc.exe命令:

protoc --proto_path=[full path where exist file[ProtobufTypes.proto] --cpp_out=[full path where exist file[ProtobufTypes.proto] [full path where exist file[ProtobufTypes.proto]/ProtobufTypes.proto

相关问题