1 year ago

#369234

test-img

Viktor Sokolov

Unable to compile Protocol Buffers (protobuf) examples in MSVS 2022 on Windows 10

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:
  1. Compiled protobuf from the source code, successfully ran tests, and got the install folder with the files: bin, cmake, include, lib
  2. 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.
  3. 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.

c++

visual-studio

compiler-errors

windows-10

protocol-buffers

0 Answers

Your Answer

Accepted video resources