添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
不羁的生姜  ·  Developer Community·  5 月前    · 
英勇无比的红酒  ·  NPC | Terraria ...·  9 月前    · 
留胡子的针织衫  ·  threejs ...·  1 年前    · 
八块腹肌的烈酒  ·  Scalable Sequence for ...·  1 年前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running environment: Windows11 x86_64 protobuf-26.1 C++

I installed the 26.1 version of protobuf and compiled it through Visual Studio 2022. Subsequently, I added \protobuf-26.1\src\google and protobuf-26.1\third_party\abseil-cpp\absl to the include files, But after I generated .pb.h and .pb.cc files through protoc.exe , the following problem occurred:

严重性	代码	说明	项目	文件	行	禁止显示状态
错误	C2039	"uniform_int_distribution": 不是 "std" 的成员	day09-protobuf-demo	D:\Development\protobuf\protobuf_dev\include\absl\algorithm\container.h	797	

I learned that uniform_int_distribution appears in C++11 and exists in the random library, and the corresponding symbol can also be found in my Visual Studio:

Is there a reason for this error?

A more detailed error message is as follows:

error information 已启动重新生成... 1>------ 已启动全部重新生成: 项目: day09-protobuf-demo, 配置: Debug x64 ------ 1>day09-protobuf-demo.cpp 1>msg.pb.cc 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\coded_stream.h(1266,28): warning C4251: “google::protobuf::io::CodedOutputStream::default_serialization_deterministic_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::io::CodedOutputStream”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\atomic(2686): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(411,22): warning C4251: “google::protobuf::internal::SerialArena::ptr_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::SerialArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(411): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(421,29): warning C4251: “google::protobuf::internal::SerialArena::string_block_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::SerialArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(421): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(426,23): warning C4251: “google::protobuf::internal::SerialArena::string_block_unused_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::SerialArena”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\atomic(2698): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(428,28): warning C4251: “google::protobuf::internal::SerialArena::head_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::SerialArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(428): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(429,23): warning C4251: “google::protobuf::internal::SerialArena::space_used_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::SerialArena”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\atomic(2698): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\serial_arena.h(430,23): warning C4251: “google::protobuf::internal::SerialArena::space_allocated_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::SerialArena”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\atomic(2698): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\thread_safe_arena.h(138,29): warning C4251: “google::protobuf::internal::ThreadSafeArena::alloc_policy_”: class“google::protobuf::internal::TaggedAllocationPolicyPtr”需要有 dll 接口由 class“google::protobuf::internal::ThreadSafeArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\arena_allocation_policy.h(41): message : 参见“google::protobuf::internal::TaggedAllocationPolicyPtr”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\thread_safe_arena.h(139,30): warning C4251: “google::protobuf::internal::ThreadSafeArena::arena_stats_”: class“google::protobuf::internal::ThreadSafeArenaStatsHandle”需要有 dll 接口由 class“google::protobuf::internal::ThreadSafeArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\arenaz_sampler.h(175): message : 参见“google::protobuf::internal::ThreadSafeArenaStatsHandle”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\thread_safe_arena.h(142,15): warning C4251: “google::protobuf::internal::ThreadSafeArena::mutex_”: class“absl::Mutex”需要有 dll 接口由 class“google::protobuf::internal::ThreadSafeArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\absl\synchronization\mutex.h(151): message : 参见“absl::Mutex”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\thread_safe_arena.h(144,34): warning C4251: “google::protobuf::internal::ThreadSafeArena::head_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::ThreadSafeArena”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\thread_safe_arena.h(144): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\thread_safe_arena.h(241,39): warning C4251: “google::protobuf::internal::ThreadSafeArena::lifecycle_id_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::ThreadSafeArena”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\atomic(2698): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\arenastring.h(60,43): warning C4251: “google::protobuf::internal::LazyString::inited_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::LazyString”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\arenastring.h(60): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\metadata_lite.h(248,15): warning C4251: “google::protobuf::internal::LiteUnknownFieldSetter::buffer_”: class“std::basic_string,std::allocator>”需要有 dll 接口由 class“google::protobuf::internal::LiteUnknownFieldSetter”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\xstring(4919): message : 参见“std::basic_string,std::allocator>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\message_lite.h(117,23): warning C4251: “google::protobuf::internal::CachedSize::atom_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::CachedSize”的客户端使用 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\atomic(2693): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\absl\algorithm\container.h(797,14): error C2039: "uniform_int_distribution": 不是 "std" 的成员 1>D:\Development\VisualStudio2022\VC\Tools\MSVC\14.32.31326\include\unordered_set(24): message : 参见“std”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(618,7): warning C4251: “google::protobuf::internal::ExtensionSet::maybe_create_lazy_extension_”: struct“std::atomic”需要有 dll 接口由 class“google::protobuf::internal::ExtensionSet”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(617): message : 参见“std::atomic”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1085,26): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_int32_t_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(285): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1086,26): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_int64_t_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(498): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1087,27): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_uint32_t_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(500): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1088,27): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_uint64_t_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(502): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1089,25): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_double_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(518): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1090,24): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_float_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(516): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\extension_set.h(1091,23): warning C4251: “google::protobuf::internal::RepeatedPrimitiveDefaults::default_repeated_field_bool_”: class“google::protobuf::RepeatedField”需要有 dll 接口由 class“google::protobuf::internal::RepeatedPrimitiveDefaults”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\wire_format_lite.h(520): message : 参见“google::protobuf::RepeatedField”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2412,7): warning C4251: “google::protobuf::DescriptorPool::dispatcher_”: class“std::unique_ptr) const>,std::default_delete) const>>>”需要有 dll 接口由 class“google::protobuf::DescriptorPool”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2411): message : 参见“std::unique_ptr) const>,std::default_delete) const>>>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2418,27): warning C4251: “google::protobuf::DescriptorPool::tables_”: class“std::unique_ptr>”需要有 dll 接口由 class“google::protobuf::DescriptorPool”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2418): message : 参见“std::unique_ptr>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2431,42): warning C4251: “google::protobuf::DescriptorPool::unused_import_track_files_”: class“absl::flat_hash_map>>”需要有 dll 接口由 class“google::protobuf::DescriptorPool”的客户端使用 1> with 1> K=std::string, 1> V=bool 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2431): message : 参见“absl::flat_hash_map>>”的声明 1> with 1> K=std::string, 1> V=bool 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2435,39): warning C4251: “google::protobuf::DescriptorPool::feature_set_defaults_spec_”: class“std::unique_ptr>”需要有 dll 接口由 class“google::protobuf::DescriptorPool”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\descriptor.h(2435): message : 参见“std::unique_ptr>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(234,30): warning C4251: “google::protobuf::io::CopyingInputStreamAdaptor::buffer_”: class“std::unique_ptr>”需要有 dll 接口由 class“google::protobuf::io::CopyingInputStreamAdaptor”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(234): message : 参见“std::unique_ptr>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(328,30): warning C4251: “google::protobuf::io::CopyingOutputStreamAdaptor::buffer_”: class“std::unique_ptr>”需要有 dll 接口由 class“google::protobuf::io::CopyingOutputStreamAdaptor”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(234): message : 参见“std::unique_ptr>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(402,28): warning C4251: “google::protobuf::io::CordInputStream::it_”: class“absl::Cord::CharIterator”需要有 dll 接口由 class“google::protobuf::io::CordInputStream”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\absl\strings\cord.h(615): message : 参见“absl::Cord::CharIterator”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(486,14): warning C4251: “google::protobuf::io::CordOutputStream::cord_”: class“absl::Cord”需要有 dll 接口由 class“google::protobuf::io::CordOutputStream”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\absl\strings\cord.h(172): message : 参见“absl::Cord”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\io\zero_copy_stream_impl_lite.h(489,20): warning C4251: “google::protobuf::io::CordOutputStream::buffer_”: class“absl::CordBuffer”需要有 dll 接口由 class“google::protobuf::io::CordOutputStream”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\absl\strings\cord_buffer.h(105): message : 参见“absl::CordBuffer”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\unknown_field_set.h(190,29): warning C4251: “google::protobuf::UnknownFieldSet::fields_”: class“std::vector>”需要有 dll 接口由 class“google::protobuf::UnknownFieldSet”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\unknown_field_set.h(190): message : 参见“std::vector>”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\map.h(761,13): warning C4251: “google::protobuf::internal::UntypedMapBase::alloc_”: class“google::protobuf::internal::MapAllocator”需要有 dll 接口由 class“google::protobuf::internal::UntypedMapBase”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\map.h(509): message : 参见“google::protobuf::internal::MapAllocator”的声明 1>D:\Development\protobuf\protobuf_dev\include\google\protobuf\message.h(1001,27): warning C4251: “google::protobuf::Reflection::tcparse_table_once_”: class“absl::once_flag”需要有 dll 接口由 class“google::protobuf::Reflection”的客户端使用 1>D:\Development\protobuf\protobuf_dev\include\absl\base\call_once.h(87): message : 参见“absl::once_flag”的声明 1>正在生成代码... 1>已完成生成项目“day09-protobuf-demo.vcxproj”的操作 - 失败。 ========== “全部重新生成”: 0 成功,1 失败,0已跳过 ==========

I'm seeing the exact same error when trying to build my project using gRPC 1.62.1 which includes protobuf 3.25.1. I'm using
Running Environment:
Windows11 x86_64
VS2022 17.9.6
Project is compiled as ISO standard C++14

[Bug]: algorithm\container.h is missing random header and causing compilation error when building protobuf in VS2022 abseil/abseil-cpp#1676

The linked issue in Abseil is fixed. The solution is as specified in the bug. Add random as a system include to container.h.
Until protobuf takes a version of abseil with this fix then this issue remains live.

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

- protobuf - 구글에서 만든 라이브러리며, 다양한 mmorpg에서 활용되는 라이브러리 - 추후에 protofile을 만들면 자동으로 언어에 맞게 파일을 만들어주는 형식 - 활용 방법 1. 코드 제작: Protocol.proto ( https://protobuf.dev/reference/protobuf/edition-2023-spec/ ) ```protobuf edition = "2023"; package Protocol; message BuffData uint64 buffId = 1; float remainTime = 2; repeated uint64 victims = 3; message S_TEST uint64 id = 1; uint32 hp = 2; uint32 attack = 3; repeated BuffData buffs = 4; - 변경점 - 기존 proto3과 다르게 syntax keyword가 edition으로 변경됨 (overview: https://protobuf.dev/editions/overview/ ) 2. 파일 복사 - 추후에 자동화를 할 예정이며, Dummy, Server에 각각 복사 수행 3. 컴파일 - 개선사항 - 저장 방식 변경 ![image.png]( https://prod-files-secure.s3.us-west-2.amazonaws.com/4cb130f0-cd8f-479e-a49b-a6bc3460c9ba/671d981c-4a94-4bb2-9f20-145aba565e87/image.png ) ![image.png]( https://prod-files-secure.s3.us-west-2.amazonaws.com/4cb130f0-cd8f-479e-a49b-a6bc3460c9ba/1b61ebba-cdd7-4e57-8e69-1e1d4f5d0366/image.png ) ![image.png]( https://prod-files-secure.s3.us-west-2.amazonaws.com/4cb130f0-cd8f-479e-a49b-a6bc3460c9ba/07eec948-bc2e-41f6-909d-ade0433decbf/image.png ) - pch.h ```cpp #pragma once #define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용을 Windows 헤더에서 제외합니다. #ifdef _DEBUG #pragma comment(lib, "Debug\\ServerCore.lib") #else #pragma comment(lib, "Release\\ServerCore.lib") #endif #include "CorePch.h" - 변경 사항 ```cpp #pragma once #define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용을 Windows 헤더에서 제외합니다. #ifdef _DEBUG #pragma comment(lib, "Debug\\ServerCore.lib") #else #pragma comment(lib, "Release\\ServerCore.lib") #endif #include "CorePch.h" - cmake간 오류 사항 - 종속성 오류 (참고: https://protobuf.dev/support/migration/ ) - Abseil LTS 20230117 이상 버전 필수 ![image.png]( https://prod-files-secure.s3.us-west-2.amazonaws.com/4cb130f0-cd8f-479e-a49b-a6bc3460c9ba/f80c4db3-ba52-4acb-8649-2bccb911d439/image.png ) - vcpkg - 커맨드: vcpkg install abseil:x64-windows - 해결방법 - protobuf/cmake/README.md 파일 참고 ```markdown ## Getting Sources You can get the latest stable source packages from the release page: https://github.com/protocolbuffers/protobuf/releases/latest Or you can use git to clone from protobuf git repository. C:\Path\to> mkdir src & cd src C:\Path\to\src> git clone -b [release_tag] https://github.com/protocolbuffers/protobuf.git Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *main* if you want to get the latest code. Go to the project folder: C:\Path\to\src> cd protobuf C:\Path\to\src\protobuf> Remember to update any submodules if you are using git clone (you can skip this step if you are using a release .tar.gz or .zip package): ```console C:\Path\to\src\protobuf> git submodule update --init --recursive Good. Now you are ready for *CMake* configuration. - 추가 에러 (v27.5, protocolbuffers/protobuf#16475 ) - container.h 파일에 #include<random> 누락으로 인한 uniform_int_distribution 에러 - 해결방법: #include<random> 추가 후 build ![image.png]( https://prod-files-secure.s3.us-west-2.amazonaws.com/4cb130f0-cd8f-479e-a49b-a6bc3460c9ba/93299f48-932a-4bbb-8c69-1b109d2ad39d/image.png ) - GameServer - ProtoBuf를 활용한 패킷 생성 - 패킷 설정 - set_ - 변수에 값 할당 - add_ - 가변길이의 경우 값 할당 및 추가 - ServerPacketHandler - 함수 추가 - MakeSendBuffer(Protocol::S_TEST& pkt) - 쓰기 버퍼에 데이터를 넣은 후 반환 1. dataSize 및 packetSize 계산 2. sendBuffer 할당 (SendBufferManager에서 데이터 크기만큼 Open) 3. header 추가 4. header 크기(packetSize) 만큼을 건너뛴 후 pkt 데이터를 복사 - 버퍼 쓰기 - SerializeToArray - ClientPacketHandler - 함수 수정 - Handle_S_TEST(BYTE* buffer, int32 len) 1. pkt에 buffer의 header를 제외하고 복사 2. 구조체를 활용하는 방식으로 받은 패킷 활용 - 범용적인 protobuf를 활용하면 다양한 프로젝트 진행 시 혼선을 줄일 수 있다. - 추가 개선 방향 - switch-case 구문을 제거하는 방향으로 개선