protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.66k stars 15.5k forks source link

Build Fails with CMake/Ninja with VS 2022 with Syntax and Type Errors #11434

Closed danyeaw closed 1 year ago

danyeaw commented 1 year ago

I am getting the following errors when trying to compile protobuf using CMake and Ninja with VS2022. This same setup works to compile version 3.15.8, but gives the following error on 3.21.12 or the latest main.

HEAD is now at bb96ec94a Migrate std::operator+ to Abseil helpers in compiler code.
Submodule 'third_party/abseil-cpp' (https://github.com/abseil/abseil-cpp.git) registered for path 'third_party/abseil-cpp'
Submodule 'third_party/googletest' (https://github.com/google/googletest.git) registered for path 'third_party/googletest'
Submodule 'third_party/jsoncpp' (https://github.com/open-source-parsers/jsoncpp.git) registered for path 'third_party/jsoncpp'
Submodule 'third_party/utf8_range' (https://github.com/protocolbuffers/utf8_range.git) registered for path 'third_party/utf8_range'
Cloning into 'C:/gtk-build/src/git-exp/protobuf/third_party/abseil-cpp'...
Cloning into 'C:/gtk-build/src/git-exp/protobuf/third_party/googletest'...
Cloning into 'C:/gtk-build/src/git-exp/protobuf/third_party/jsoncpp'...
Cloning into 'C:/gtk-build/src/git-exp/protobuf/third_party/utf8_range'...
Submodule path 'third_party/abseil-cpp': checked out '273292d1cfc0a94a65082ee350509af1d113344d'
Submodule path 'third_party/googletest': checked out '4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774'
Submodule path 'third_party/jsoncpp': checked out '9059f5cad030ba11d37818847443a53918c327b1'
Submodule path 'third_party/utf8_range': checked out 'de0b4a8ff9b5d4c98108bdfe723291a33c52c54f'
(git) Exporting directory C:\gtk-build\build\x64\release\protobuf
Building project protobuf (git/bb96ec94af136216e4c3195166d1d80dd2bcf8a6)
-- The C compiler identification is MSVC 19.34.31937.0
-- The CXX compiler identification is MSVC 19.34.31937.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped       
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--
-- 3.21.4.0
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found ZLIB: C:/gtk-build/gtk/x64/release/lib/zlib1.lib (found version "1.2.13") 
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    GTK_DIR

-- Build files have been written to: C:/gtk-build/build/x64/release/protobuf/_gvsbuild-cmake
[3/389] Building CXX object CMakeFiles\libprotobuf-lite.dir\src\google\protobuf\arena_align.cc.obj
FAILED: CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/arena_align.cc.obj
C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\cl.exe  /nologo /TP -DGOOGLE_PROTOBUF_CMAKE_BUILD -DHAVE_ZLIB -IC:\gtk-build\gtk\x64\re
lease\include -IC:\gtk-build\build\x64\release\protobuf\_gvsbuild-cmake -IC:\gtk-build\build\x64\release\protobuf\src -IC:\gtk-build\build\x64\release\protobuf\thi
rd_party\utf8_range -IC:\gtk-build\build\x64\release\protobuf\third_party\abseil-cpp /DWIN32 /D_WINDOWS /W3 /GR /EHsc /O2 /Ob2 /DNDEBUG -MD /MP /utf-8 /wd4065 /wd4
244 /wd4251 /wd4267 /wd4305 /wd4307 /wd4309 /wd4334 /wd4355 /wd4506 /wd4800 /wd4996 /bigobj -std:c++14 /showIncludes /FoCMakeFiles\libprotobuf-lite.dir\src\google\
protobuf\arena_align.cc.obj /FdCMakeFiles\libprotobuf-lite.dir\libprotobuf-lite.pdb /FS -c C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arena_align.cc
C:\gtk-build\build\x64\release\protobuf\src\google/protobuf/arena_align.h(102): warning C4146: unary minus operator applied to unsigned type, result still unsigned
C:\gtk-build\build\x64\release\protobuf\src\google/protobuf/arena_align.h(109): error C3861: 'ABSL_ASSERT': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google/protobuf/arena_align.h(145): warning C4146: unary minus operator applied to unsigned type, result still unsigned
C:\gtk-build\build\x64\release\protobuf\src\google/protobuf/arena_align.h(152): error C3861: 'ABSL_ASSERT': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google/protobuf/arena_align.h(178): error C3861: 'GOOGLE_ABSL_DCHECK_NE': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google/protobuf/arena_align.h(179): error C3861: 'GOOGLE_ABSL_DCHECK': identifier not found
[4/389] Building CXX object CMakeFiles\libprotobuf-lite.dir\src\google\protobuf\any_lite.cc.obj
FAILED: CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/any_lite.cc.obj
C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\cl.exe  /nologo /TP -DGOOGLE_PROTOBUF_CMAKE_BUILD -DHAVE_ZLIB -IC:\gtk-build\gtk\x64\re
lease\include -IC:\gtk-build\build\x64\release\protobuf\_gvsbuild-cmake -IC:\gtk-build\build\x64\release\protobuf\src -IC:\gtk-build\build\x64\release\protobuf\thi
rd_party\utf8_range -IC:\gtk-build\build\x64\release\protobuf\third_party\abseil-cpp /DWIN32 /D_WINDOWS /W3 /GR /EHsc /O2 /Ob2 /DNDEBUG -MD /MP /utf-8 /wd4065 /wd4
244 /wd4251 /wd4267 /wd4305 /wd4307 /wd4309 /wd4334 /wd4355 /wd4506 /wd4800 /wd4996 /bigobj -std:c++14 /showIncludes /FoCMakeFiles\libprotobuf-lite.dir\src\google\protobuf\any_lite.cc.obj /FdCMakeFiles\libprotobuf-lite.dir\libprotobuf-lite.pdb /FS -c C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc    
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc(56): error C2511: 'bool google::protobuf::internal::AnyMetadata::InternalPackFrom(google::p
rotobuf::Arena *,const google::protobuf::MessageLite &,absl::lts_20220623::string_view,absl::lts_20220623::string_view)': overloaded member function not found in 'google::protobuf::internal::AnyMetadata'
C:\gtk-build\gtk\x64\release\include\google/protobuf/any.h(58): note: see declaration of 'google::protobuf::internal::AnyMetadata'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc(63): error C2511: 'bool google::protobuf::internal::AnyMetadata::InternalUnpackTo(absl::lts_20220623::string_view,google::protobuf::MessageLite *) const': overloaded member function not found in 'google::protobuf::internal::AnyMetadata'
C:\gtk-build\gtk\x64\release\include\google/protobuf/any.h(58): note: see declaration of 'google::protobuf::internal::AnyMetadata'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc(65): error C2664: 'bool google::protobuf::internal::AnyMetadata::InternalIs(google::protobuf::StringPiece) const': cannot convert argument 1 from 'absl::lts_20220623::string_view' to 'google::protobuf::StringPiece'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc(65): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\gtk-build\gtk\x64\release\include\google/protobuf/any.h(116): note: see declaration of 'google::protobuf::internal::AnyMetadata::InternalIs'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc(65): note: while trying to match the argument list '(absl::lts_20220623::string_view)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\any_lite.cc(71): error C2511: 'bool google::protobuf::internal::AnyMetadata::InternalIs(absl::lts_20220623::string_view) const': overloaded member function not found in 'google::protobuf::internal::AnyMetadata'
C:\gtk-build\gtk\x64\release\include\google/protobuf/any.h(58): note: see declaration of 'google::protobuf::internal::AnyMetadata'
[5/389] Building CXX object CMakeFiles\libprotobuf-lite.dir\src\google\protobuf\arenastring.cc.obj
FAILED: CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/arenastring.cc.obj
C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\cl.exe  /nologo /TP -DGOOGLE_PROTOBUF_CMAKE_BUILD -DHAVE_ZLIB -IC:\gtk-build\gtk\x64\re
lease\include -IC:\gtk-build\build\x64\release\protobuf\_gvsbuild-cmake -IC:\gtk-build\build\x64\release\protobuf\src -IC:\gtk-build\build\x64\release\protobuf\thi
rd_party\utf8_range -IC:\gtk-build\build\x64\release\protobuf\third_party\abseil-cpp /DWIN32 /D_WINDOWS /W3 /GR /EHsc /O2 /Ob2 /DNDEBUG -MD /MP /utf-8 /wd4065 /wd4
244 /wd4251 /wd4267 /wd4305 /wd4307 /wd4309 /wd4334 /wd4355 /wd4506 /wd4800 /wd4996 /bigobj -std:c++14 /showIncludes /FoCMakeFiles\libprotobuf-lite.dir\src\google\
protobuf\arenastring.cc.obj /FdCMakeFiles\libprotobuf-lite.dir\libprotobuf-lite.pdb /FS -c C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(68): error C2061: syntax error: identifier 'ExplicitlyConstructedArenaString'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(93): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(93): error C2143: syntax error: missing ',' before '*'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(99): error C7525: inline variables require at least '/std:c++17'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(99): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(99): error C2146: syntax error: missing ';' before identifier 'CreateString'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(99): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(100): error C2146: syntax error: missing ';' before identifier 'res'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(100): error C2065: 'res': undeclared identifier
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(101): error C2065: 'res': undeclared identifier
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(102): error C2065: 'res': undeclared identifier
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(108): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(108): error C2086: 'int google::protobuf::internal::`anonymous-namespace'::TaggedStringPtr': redefinition
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(99): note: see declaration of 'google::protobuf::internal::`anonymous-namespace'::TaggedStringPtr'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(108): error C2146: syntax error: missing ';' before identifier 'CreateArenaString'      
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(108): error C2143: syntax error: missing ';' before '{'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(108): error C2447: '{': missing function header (old-style formal list?)
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(118): error C2511: 'void google::protobuf::internal::ArenaStringPtr::Set(absl::lts_20220623::string_view,google::protobuf::Arena *)': overloaded member function not found in 'google::protobuf::internal::ArenaStringPtr'
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(175): note: see declaration of 'google::protobuf::internal::ArenaStringPtr'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): error C2665: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants': no overloaded function could convert all the argument types
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: could be 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(93): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const int)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const int)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const int'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: There is no context in which this conversion is possible
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(119): note: while trying to match the argument list '(google::protobuf::internal::TaggedPtr<std::string> *)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(120): error C2660: 'google::protobuf::internal::ArenaStringPtr::IsDefault': function does not take 0 arguments
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(283): note: see declaration of 'google::protobuf::internal::ArenaStringPtr::IsDefault'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(120): note: while trying to match the argument list '()'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(123): error C3861: 'CreateArenaString': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(137): error C2352: 'google::protobuf::internal::ArenaStringPtr::UnsafeMutablePointer': a call of a non-static member function requires an object
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(368): note: see declaration of 'google::protobuf::internal::ArenaStringPtr::UnsafeMutablePointer'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(143): error C2910: 'google::protobuf::internal::ArenaStringPtr::Set': cannot be explicitly specialized
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(167): error C2511: 'void google::protobuf::internal::ArenaStringPtr::Set(std::string &&,google::protobuf::Arena *)': overloaded member function not found in 'google::protobuf::internal::ArenaStringPtr'
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(175): note: see declaration of 'google::protobuf::internal::ArenaStringPtr'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): error C2665: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants': no overloaded function could convert all the argument types
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: could be 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(93): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const int)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const int)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const int'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: There is no context in which this conversion is possible
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(168): note: while trying to match the argument list '(google::protobuf::internal::TaggedPtr<std::string> *)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(169): error C2660: 'google::protobuf::internal::ArenaStringPtr::IsDefault': function does not take 0 arguments
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(283): note: see declaration of 'google::protobuf::internal::ArenaStringPtr::IsDefault'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(169): note: while trying to match the argument list '()'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(170): error C3861: 'NewString': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(171): error C3861: 'IsFixedSizeArena': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(175): error C2039: 'SetMutableArena': is not a member of 'google::protobuf::internal::TaggedPtr<std::string>'
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(116): note: see declaration of 'google::protobuf::internal::TaggedPtr<std::string>'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(177): error C2352: 'google::protobuf::internal::ArenaStringPtr::UnsafeMutablePointer': a call of a non-static member function requires an object
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(368): note: see declaration of 'google::protobuf::internal::ArenaStringPtr::UnsafeMutablePointer'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(181): error C2511: 'std::string *google::protobuf::internal::ArenaStringPtr::Mutable(google::protobuf::Arena *)': overloaded member function not found in 'google::protobuf::internal::ArenaStringPtr'
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(175): note: see declaration of 'google::protobuf::internal::ArenaStringPtr'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): error C2665: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants': no overloaded function could convert all the argument types
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: could be 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(93): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const int)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const int)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'const int'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: There is no context in which this conversion is possible
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(182): note: while trying to match the argument list '(google::protobuf::internal::TaggedPtr<std::string> *)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(183): error C2039: 'IsMutable': is not a member of 'google::protobuf::internal::TaggedPtr<std::string>'
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(116): note: see declaration of 'google::protobuf::internal::TaggedPtr<std::string>'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(186): error C2352: 'google::protobuf::internal::ArenaStringPtr::MutableSlow': a call of a non-static member function requires an object
C:\gtk-build\gtk\x64\release\include\google/protobuf/arenastring.h(301): note: see declaration of 'google::protobuf::internal::ArenaStringPtr::MutableSlow'        
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(192): error C2665: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants': no overloaded function could convert all the argument types
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: could be 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(192): note: 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants
::ScopedCheckPtrInvariants(google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&)': cannot convert argument 1 from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &&'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(192): note: Reason: cannot convert from 'google::protobuf::internal::TaggedPtr<std::string> *' to 'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(192): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\arenastring.cc(94): note: or       'google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants::ScopedCheckPtrInvariants(const google::protobuf::internal::`anonymous-namespace'::ScopedCheckPtrInvariants &)'

... Another thousand lines of errors ...

C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\extension_set.cc(374): error C3861: 'GOOGLE_ABSL_DCHECK_EQ': identifier not found
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\extension_set.cc(374): error C2039: 'GetRefBool': is not a member of 'google::protobuf::internal::ExtensionSet'
C:\gtk-build\gtk\x64\release\include\google/protobuf/extension_set.h(174): note: see declaration of 'google::protobuf::internal::ExtensionSet'
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\extension_set.cc(374): error C2270: 'GetRefBool': modifiers not allowed on nonmember functions
C:\gtk-build\build\x64\release\protobuf\src\google\protobuf\extension_set.cc(374): fatal error C1003: error count exceeds 100; stopping compilation
ninja: build stopped: subcommand failed.

What version of protobuf and what language are you using? Version: main and 3.21.12 Language: C++

What operating system (Linux, Windows, ...) and version? Windows 11

What runtime / compiler are you using (e.g., python version or gcc version) Visual Studio 2022 using visualstudio2022-workload-vctools CLI

What did you do? Build flags for CMake are -DCMAKE_BUILD_TYPE=Release -Dprotobuf_DEBUG_POSTFIX="" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=ON -Dprotobuf_MSVC_STATIC_RUNTIME=OFF

What did you expect to see A successful build

What did you see instead? Build errors

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

acozzette commented 1 year ago

@danyeaw My best guess is that your build is somehow mixing more than one version of the protobuf runtime library. For example, GOOGLE_ABSL_DCHECK_NE is defined here in logging.h, but if the compiler is using an old version of that header then that definition won't be there. I think that would explain the other errors as well. Are there maybe some old protobuf headers lying around on your system somewhere?

danyeaw commented 1 year ago

Thanks @acozzette! I thought I had a clean build before when I was getting those errors, but I just wiped everything and started over, and now everything is building successfully. Thanks for the help, and apologies for opening an issue when one didn't really exist.

acozzette commented 1 year ago

No worries, I'm glad you got it sorted out!