Undefined symbols when using grpc

Hello everyone, I am trying to integrate GRPC into UE 5.1.1, but unfortunately, I am a beginner in this area.I developed in Win11 and packaged it on the Linux platform through cross compilation tools.Fortunately, I found the following article in the community
https://forums.unrealengine.com/t/compiling-libraries-in-linux/400275/11
https://forums.unrealengine.com/t/add-grpc-and-protobuf-to-ue4-build-failed-without-libcxx/406543/11
I followed the latest comments and compiled all GRPC libraries in Linux (ubuntu 16.0.2) using the corresponding versions of clang, libc++. a, and ssl from ue5.1.1. I confirm that this method is effective as it solves most of the undefined symbols and redefinitions。
But when I tried to package, I encountered the following error (excerpt)

ld.lld: error: undefined symbol: absl::base_internal::LowLevelAlloc::Free(void*)
UATHelper: pack (Linux): >>> referenced by create_thread_identity.cc
UATHelper: pack (Linux): >>>               create_thread_identity.o:(absl::synchronization_internal::ReclaimThreadIdentity(void*)) in archive F:/UE4/UE_5.1/Engine/Source/ThirdParty/WebRTC/4664/Lib/Linux/x86_64-unknown-linux-gnu/Release/libwebrtc.a

All undefined symbol references are libwebrtc. a and errors are on these two functions: absl:: base_ Internal:: LowLevelAlloc:: Free (void *) and absl:: base_ Internal:: LowLevelAlloc:: Alloc (unsigned long).
I think this may be a difference between the ABSL library I used to build GRPC and libwebrtc. a, but I am not sure about this, so I would like to ask how to solve this problem. Also, is it possible to use the same ABSL library as building libwebrtc to build GRPC? (I cannot find a method to confirm the Absl library used by libwebrtc)
Also, this is my way of referencing third-party libraries. I know I should use third-party library plugins, but for the purpose of preliminary testing, I did this first(perhaps this is also the reason?) and In addition, this is the build. cs for the Windows platform. I did the same thing on the Linux platform, but referenced. a instead of. lib. The current computer does not have this version of the project. I am very sorry.

private string ModulePath
    {
        get
        {
            return ModuleDirectory;
        }
    }
    private string ThirdPartyPath
    {
        get
        {
            return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty"));
        }
    }
    public DigitalMan(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        PrivateIncludePaths.AddRange(
               new string[] {
                    "MyProject",
                         "MyProject/HttpLogic"
               }
           );

        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" ,
             "Sockets",
        "Networking" ,
            "Json",
            "HTTP" ,
       "HTTPServer",
      "JsonUtilities"
        });

        PrivateDependencyModuleNames.AddRange(new string[] { });

        // Uncomment if you are using Slate UI
        // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");

        // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
        PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "include"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_bad_optional_access.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_bad_variant_access.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_base.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_city.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_civil_time.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_cord.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_debugging_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_demangle_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_exponential_biased.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_graphcycles_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_hash.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_hashtablez_sampler.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_int128.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_log_severity.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_malloc_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_raw_hash_set.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_raw_logging_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_spinlock_wait.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_stacktrace.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_status.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_str_format_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_strings.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_strings_internal.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_symbolize.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_synchronization.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_throw_delegate.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_time.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "absl_time_zone.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "address_sorting.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "cares.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "crypto.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "gpr.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc_plugin_support.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc_unsecure.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc++.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc++_alts.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc++_error_details.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc++_reflection.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpc++_unsecure.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "grpcpp_channelz.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "libprotobuf.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "libprotobuf-lite.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "libprotoc.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "re2.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "ssl.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "upb.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "zlib.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "lib", "zlibstatic.lib"));
        bEnableUndefinedIdentifierWarnings = false;
    }

Thank you in advance for your valuable suggestions

Hello everyone, today my colleagues and I have solved this problem together.
We first removed several GRPC dependency libraries, which obviously resulted in undefined errors. for example

UATHelper: 打包 (Linux): ld.lld: error: undefined symbol: absl::lts_2020_09_23::base_internal::SpinLockWait(std::__1::atomic<unsigned int>*, int, absl::lts_2020_09_23::base_internal::SpinLockWaitTransition const*, absl::lts_2020_09_23::base_internal::SchedulingMode)

We found a significant difference between these symbols and the symbols in the UE library

UATHelper: 打包 (Linux): ld.lld: error: undefined symbol: absl::base_internal::LowLevelAlloc::Free(void*)

There is a version number in its namespace.Therefore, in the configuration of the third-party dependency library ABSL in GRPC, the path is as follows

grpc/third_party/abseil-cpp/absl/base/options.h

change ABSL_OPTION_USE_INLINE_NAMESPACE to 0,Your version number may be different

#define ABSL_OPTION_USE_INLINE_NAMESPACE 1
#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_2020_09_23
#define ABSL_OPTION_USE_INLINE_NAMESPACE 0

Save and recompile all grpc libraries, now package again, everything is normal!My GRPC version is 1.34.0, and I’m not sure if this issue exists in a higher version. I’m just proposing an effective solution for me, and I look forward to more people’s answers. Good luck to everyone!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.