我正在尝试开发一个程序来演示protobuf的使用
软件包管理器:vcpkg
C++标准:C++20
Microsoft 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:UsersDarkSorrowAppDataLocalvcpkgarchives 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=.
代码(test.proto(:
syntax = "proto3";
message Person {
optional string name = 1;
optional int32 id = 2;
optional string email = 3;
}
协议缓冲区生成器版本
protoc --version
libprotoc 3.16.0
您必须执行: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