i am trying to include protobuf lastest version 3.26.1 (ver 2024-04) in unreal 5. (i am using vs2022 community)
when i include protobuf using thirdparty abseil-cpp,
i face compile error C2373(redefinition). like below
Error C2373 ‘absl::container_internal::node_type’: redefinition; different type modifiers TestProtoForUnreal C:\Users\blackstorm_kdongin\Documents\Unreal Projects\TestProtoForUnreal\Source\ThirdParty\abseilcpp\absl\container\internal\btree.h 1653
it seems that absl\container\internal\btree.h causes that error.
i assume that it conflicts with another absl\btree.h included unreal engine 5 some where.
i found out several same abseil in unreal engine 5.
could you fix or recommend a workaround???
I have encountered another problem and I am not sure if it will be helpful to you
protobuf version 3.26.1 (ver 2024-04)
Unreal Engine version 5.3
vs2022 community
Reason:
The function verify() defined in the absl/container/internal/btree. h and absl/container/internal/btree. container.h files conflicts with the verify(expr) macro defined in UE5.
Solution:
In the context of function definition, cancel the macro definition of UE.
This is the code that I have personally modified, and there may be other ways to modify it.
Around line 1579 of the btree.h file, after modification:
#ifdef verify
#undef verify
#endif
// Verifies the structure of the btree.
void verify() const;
#ifndef verify
#define verify(expr) UE_CHECK_IMPL(expr) // copy from line 221 of /Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h
#endif
Around line 2610 of the btree.h file, after modification:
I am using UE5.3.2,threepotato’s solution could work if you are building a standalone application,but in my case I was building a plugin,it works fine during development,but would result in a failure if you try to package your plugin.so I tried a more aggressive way: I just delete thost two verify functions,they seems to be for test only.Also I uploaded the lib to github with some building instructions.
Thank you so much for your idea - it is a lifesaver!
To save some time for others, you can avoid the third-party code modification by applying the suggested solution before including the grpc-related headers.
For example, like that:
#ifdef verify
#undef verify
#endif
#include <grpc/grpc.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h>
// … whatever else you may need to include from the gRPC framework
#include "build/myGeneratedHeader.grpc.pb.h" // This should be generated from your .proto file using protoc with gRPC plugin
#ifndef verify
#define verify(expr) UE_CHECK_IMPL(expr) // copy from line 221 of /Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h
#endif