在Windows 10上的MSVS 2022中无法编译协议缓冲区(Protobuf)示例
我正在尝试从此处编译一个Protobuf示例: https://developers.google.google。 com/protocol-buffers/doc/cpptutorial 。 我的系统配置:
- Windows 10 Pro,
- Visual Studion 2022(社区编辑),带有用于桌面开发的C ++软件包,
- Protobuf v3.20.0(最新版本)。 我已经完成了以下步骤:
- 从源代码中编译了Protobuf,成功运行了测试,并使用文件 install 文件夹: bin , cmake , include , lib
- 使用 protoc.exe 生成.cpp和.h文件后,我将它们添加到VS项目中,还包括 libprotobuf.lib 。 VC ++目录 - >包括目录。
- 在vs 2022中构建控制台应用程序时,我遇到了很多错误,这在这篇文章中不可能适合,这是其中一些错误:
Error (active) E2614 nonvirtual function cannot be declared with 'final' modifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 619
Error (active) E2614 nonvirtual function cannot be declared with 'final' modifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 633
Error (active) E2614 nonvirtual function cannot be declared with 'final' modifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 635
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 12
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 16
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 22
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 33
Error (active) E0470 the global scope has no tag named "TableStruct_addressbook_2eproto" ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 263
Error (active) E0470 the global scope has no tag named "TableStruct_addressbook_2eproto" ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 512
Error (active) E0470 the global scope has no tag named "TableStruct_addressbook_2eproto" ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 671
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 37
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 59
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 63
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 358
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 607
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 1053
NB:我只是C ++的初学者,所以我对汇编一无所知过程,如何在vs 2022中进行设置,以及在帖子中包含哪些错误。
I'm trying to compile a protobuf example from here: https://developers.google.com/protocol-buffers/docs/cpptutorial.
My system configuration:
- Windows 10 Pro,
- Visual studion 2022 (Community Ed.) with C++ Package for Desktop Development,
- Protobuf v3.20.0 (Latest Version).
I've done the following steps:
- Compiled protobuf from the source code, successfully ran tests, and got the install folder with the files: bin, cmake, include, lib
- After generating .cpp and .h files using protoc.exe, I added them to the VS project and also included libprotobuf.lib.Then, I specified path to the include folder in the project properties -> VC++ Directories -> Include Directories.
- While building console application in VS 2022, I was getting a lot of errors, which impossible to fit in in this post, here is some of them:
Error (active) E2614 nonvirtual function cannot be declared with 'final' modifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 619
Error (active) E2614 nonvirtual function cannot be declared with 'final' modifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 633
Error (active) E2614 nonvirtual function cannot be declared with 'final' modifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 635
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 12
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 16
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 22
Error (active) E0393 pointer to incomplete class type "tutorial::Person" is not allowed ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 33
Error (active) E0470 the global scope has no tag named "TableStruct_addressbook_2eproto" ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 263
Error (active) E0470 the global scope has no tag named "TableStruct_addressbook_2eproto" ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 512
Error (active) E0470 the global scope has no tag named "TableStruct_addressbook_2eproto" ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 671
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 37
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 59
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 63
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 358
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 607
Error (active) E0077 this declaration has no storage class or type specifier ConsoleApplication1 C:\Cpp_Projects\Protobuf\Demo\Project\ConsoleApplication1\ConsoleApplication1\addressbook.pb.h 1053
NB: I'm only a beginner in C++, so I understand very little about the compilation process, how to setup it in VS 2022, and what errors are relevant to include in the post.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论