s2client-api icon indicating copy to clipboard operation
s2client-api copied to clipboard

Build fails

Open Chaojimengnan opened this issue 3 years ago • 5 comments

I used VS2022 and CMake version 3.21.1 for the build. Here is my error message:

[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(294,38): error C2374: 'kRepHeaderSize': redefinition; multiple initialization [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(294): message : see declaration of 'kRepHeaderSize' [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(295): message : while compiling class template static data member 'const size_t google::protobuf::RepeatedField<google::protobuf::int32>::kRepHeaderSize' [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(1043): message : while compiling class template member function 'int google::protobuf::RepeatedField<google::protobuf::int32>::size(void) const' [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/descriptor.pb.h(4052): message : see reference to function template instantiation 'int google::protobuf::RepeatedField<google::protobuf::int32>::size(void) const' being compiled [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/descriptor.pb.h(509): message : see reference to class template instantiation 'google::protobuf::RepeatedField<google::protobuf::int32>' being compiled [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build]   field_mask.pb.cc
[build]   generated_message_reflection.cc
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(294,38): error C2374: 'kRepHeaderSize': redefinition; multiple initialization [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(294): message : see declaration of 'kRepHeaderSize' [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(295): message : while compiling class template static data member 'const size_t google::protobuf::RepeatedField<google::protobuf::int32>::kRepHeaderSize' [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/repeated_field.h(1043): message : while compiling class template member function 'int google::protobuf::RepeatedField<google::protobuf::int32>::size(void) const' [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/descriptor.pb.h(4052): message : see reference to function template instantiation 'int google::protobuf::RepeatedField<google::protobuf::int32>::size(void) const' being compiled [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]
[build] D:\base\projects\s2client-api\contrib\protobuf\src\google/protobuf/descriptor.pb.h(509): message : see reference to class template instantiation 'google::protobuf::RepeatedField<google::protobuf::int32>' being compiled [D:\base\projects\s2client-api\output\x64\Release\contrib\protobuf\cmake\libprotobuf.vcxproj]

This looks like protobuf's problem, here is the definition of kRepHeaderSize, I don't think there is something wrong, but it gets error

template<typename Element>
const size_t RepeatedField<Element>::kRepHeaderSize =
    reinterpret_cast<size_t>(&reinterpret_cast<Rep*>(16)->elements[0]) - 16;

Chaojimengnan avatar Feb 06 '22 12:02 Chaojimengnan

Hi @Chaojimengnan This API is outdated and doesn't support fresh tools, please try with https://github.com/cpp-sc2/cpp-sc2 Another solution is manual update of the protobuf submodule.

alkurbatov avatar Feb 06 '22 13:02 alkurbatov

Hi @Chaojimengnan This API is outdated and doesn't support fresh tools, please try with https://github.com/cpp-sc2/cpp-sc2 Another solution is manual update of the protobuf submodule.

It works, thank you!!

Chaojimengnan avatar Feb 07 '22 04:02 Chaojimengnan

@alkurbatov hi Can you please tell me where is the root of the problem? what needs to be updated and edited? I have the same problem in another project.

Andrysky avatar Apr 22 '22 18:04 Andrysky

Hi @Andrysky The root is in the newer compiler. Simple fix for this problem (in case you don't want to use my fork) is to update the protobuf submodule, all the needed fixes are already there.

alkurbatov avatar Apr 22 '22 18:04 alkurbatov