When your project links to libprotobuf, you may get the following errors:
libprotobuf.lib(descriptor.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(common.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(message_lite.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(arenastring.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(generated_message_util.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(message.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(coded_stream.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(arena.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(repeated_ptr_field.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(wire_format_lite.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(parse_context.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(unknown_field_set.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(generated_message_reflection.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(wire_format.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(generated_message_bases.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(zero_copy_stream.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(stringpiece.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(strutil.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(repeated_field.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(text_format.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(descriptor.pb.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(tokenizer.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(stringprintf.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(substitute.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(descriptor_database.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(dynamic_message.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(strtod.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(any_lite.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(status.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(int128.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(zero_copy_stream_impl_lite.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(zero_copy_stream_impl.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(extension_set.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(reflection_ops.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(map_field.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(implicit_weak_message.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(structurally_valid.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(extension_set_heavy.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(any.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(io_win32.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj libprotobuf.lib(map.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in mocs_compilation.cpp.obj msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (?_Getcvt@_Locinfo@std@@QEBA?AU_Cvtvec@@XZ) already defined in libprotobuf.lib(descriptor.cc.obj) msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z) already defined in libprotobuf.lib(descriptor.cc.obj) msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z) already defined in libprotobuf.lib(descriptor.cc.obj) msvcprt.lib(MSVCP140.dll) : error LNK2005: "public: void __cdecl std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z) already defined in libprotobuf.lib(descriptor.cc.obj)
This is because your project was configured to link to the dynamic library of libprotobuf, while libprotobuf was configured and built as a static library. You should re-configure/rebuild/reinstall libprotobuf dynamic library as follows:
cmake -G Ninja -S C:\protobuf-21.12 -B C:\protobuf-21.12build -DCMAKE_INSTALL_PREFIX=C:\protobuf -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_BUILD_TYPE=Release cd C:\protobuf-21.12build ninja ninja install
Note the CMake protobuf_MSVC_STATIC_RUNTIME option should be turned off explicitly because it is turned on by default.