c++linkergrpcgrpc-c++

grpc core undefined references for c++ grpc v1.50?


I built gRPC from source with cmake.
I then build my client which is gRPC based with cmake. As far as I understand the linking error I get is not related to my source code but perhaps a configuration issue. The weirder thing is that the libraries the linker complains about should be a part of the libgrpc++.a(based on gRPC cmake.)

the failed command

/usr/bin/c++ -Werror -g  xxxx/my/client/CMakeFiles/my_client.dir/my_client.cc.o           \
-o /tmp/my_client  -W xxxx/my/proto/libmy_core.a   /usr/local/lib/libgrpc++_reflection.a  \
 /usr/local/lib/libgrpc++.a /usr/local/lib/libprotobuf.a

error log

/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::set_call(grpc_call*, std::shared_ptr<grpc::Channel> const&)':
client_context.cc:(.text+0x213): undefined reference to `absl::lts_20220623::Mutex::Lock()'
/usr/bin/ld: client_context.cc:(.text+0x2e0): undefined reference to `grpc_call_cancel'
/usr/bin/ld: client_context.cc:(.text+0x2e8): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: client_context.cc:(.text+0x31a): undefined reference to `grpc_call_cancel_with_status'
/usr/bin/ld: client_context.cc:(.text+0x382): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::TryCancel()':
client_context.cc:(.text+0x3f3): undefined reference to `absl::lts_20220623::Mutex::Lock()'
/usr/bin/ld: client_context.cc:(.text+0x40d): undefined reference to `grpc_call_cancel'
/usr/bin/ld: client_context.cc:(.text+0x415): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: client_context.cc:(.text+0x428): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::peer[abi:cxx11]() const':
client_context.cc:(.text+0x468): undefined reference to `grpc_call_get_peer'
/usr/bin/ld: client_context.cc:(.text+0x490): undefined reference to `gpr_free'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::SetGlobalCallbacks(grpc::ClientContext::GlobalCallbacks*)':
client_context.cc:(.text+0x502): undefined reference to `gpr_log'
/usr/bin/ld: client_context.cc:(.text+0x532): undefined reference to `gpr_log'
/usr/bin/ld: client_context.cc:(.text+0x562): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::ClientContext()':
client_context.cc:(.text+0x5b0): undefined reference to `gpr_inf_future'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::~ClientContext()':
client_context.cc:(.text+0x8ab): undefined reference to `grpc_call_unref'
/usr/bin/ld: client_context.cc:(.text+0xaa7): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::set_compression_algorithm(grpc_compression_algorithm)':
client_context.cc:(.text+0xf1b): undefined reference to `grpc_compression_algorithm_name'
/usr/bin/ld: client_context.cc:(.text+0x10c2): undefined reference to `gpr_log'
/usr/bin/ld: client_context.cc:(.text+0x10ec): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::set_credentials(std::shared_ptr<grpc::CallCredentials> const&)':
client_context.cc:(.text+0x165): undefined reference to `grpc_call_cancel_with_status'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::internal::GrpcLibrary::shutdown()':
client_context.cc:(.text._ZN4grpc8internal11GrpcLibrary8shutdownEv[_ZN4grpc8internal11GrpcLibrary8shutdownEv]+0x5): undefined reference to `grpc_shutdown'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::internal::GrpcLibrary::init()':
client_context.cc:(.text._ZN4grpc8internal11GrpcLibrary4initEv[_ZN4grpc8internal11GrpcLibrary4initEv]+0x5): undefined reference to `grpc_init'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::set_call(grpc_call*, std::shared_ptr<grpc::Channel> const&) [clone .cold]':
client_context.cc:(.text.unlikely+0x9): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::TryCancel() [clone .cold]':
client_context.cc:(.text.unlikely+0x1a): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_context.cc.o): in function `grpc::ClientContext::ClientContext() [clone .cold]':
client_context.cc:(.text.unlikely+0xcf): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(create_channel.cc.o): in function `grpc::CreateCustomChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc::ChannelCredentials> const&, grpc::ChannelArguments const&)':
create_channel.cc:(.text+0xa9): undefined reference to `grpc_lame_client_channel_create'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(create_channel.cc.o): in function `grpc::experimental::CreateCustomChannelWithInterceptors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc::ChannelCredentials> const&, grpc::ChannelArguments const&, std::vector<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface, std::default_delete<grpc::experimental::ClientInterceptorFactoryInterface> >, std::allocator<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface, std::default_delete<grpc::experimental::ClientInterceptorFactoryInterface> > > >)':
create_channel.cc:(.text+0x330): undefined reference to `grpc_lame_client_channel_create'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(insecure_credentials.cc.o): in function `grpc::(anonymous namespace)::InsecureChannelCredentialsImpl::CreateChannelWithInterceptors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, grpc::ChannelArguments const&, std::vector<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface, std::default_delete<grpc::experimental::ClientInterceptorFactoryInterface> >, std::allocator<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface, std::default_delete<grpc::experimental::ClientInterceptorFactoryInterface> > > >)':
insecure_credentials.cc:(.text+0x1b8): undefined reference to `grpc_insecure_credentials_create'
/usr/bin/ld: insecure_credentials.cc:(.text+0x1ec): undefined reference to `grpc_channel_create'
/usr/bin/ld: insecure_credentials.cc:(.text+0x26e): undefined reference to `grpc_channel_credentials_release'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(insecure_credentials.cc.o): in function `grpc::(anonymous namespace)::InsecureChannelCredentialsImpl::CreateChannelImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, grpc::ChannelArguments const&)':
insecure_credentials.cc:(.text+0x327): undefined reference to `grpc_insecure_credentials_create'
/usr/bin/ld: insecure_credentials.cc:(.text+0x35f): undefined reference to `grpc_channel_create'
/usr/bin/ld: insecure_credentials.cc:(.text+0x3ea): undefined reference to `grpc_channel_credentials_release'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::~ChannelArguments()':
channel_arguments.cc:(.text+0xc4): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text+0xe6): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text+0x109): undefined reference to `vtable for grpc_core::ScopedTimeCache'
/usr/bin/ld: channel_arguments.cc:(.text+0x124): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text+0x13b): undefined reference to `grpc_core::Fork::support_enabled_'
/usr/bin/ld: channel_arguments.cc:(.text+0x158): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text+0x191): undefined reference to `grpc_core::ExecCtx::Flush()'
/usr/bin/ld: channel_arguments.cc:(.text+0x1a8): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text+0x1e0): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text+0x28b): undefined reference to `grpc_core::Fork::support_enabled_'
/usr/bin/ld: channel_arguments.cc:(.text+0x29b): undefined reference to `grpc_core::Fork::DoDecExecCtxCount()'
/usr/bin/ld: channel_arguments.cc:(.text+0x2a9): undefined reference to `grpc_core::Fork::DoIncExecCtxCount()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::SetSocketMutator(grpc_socket_mutator*)':
channel_arguments.cc:(.text+0x384): undefined reference to `grpc_socket_mutator_to_arg(grpc_socket_mutator*)'
/usr/bin/ld: channel_arguments.cc:(.text+0x408): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text+0x432): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text+0x454): undefined reference to `vtable for grpc_core::ScopedTimeCache'
/usr/bin/ld: channel_arguments.cc:(.text+0x477): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text+0x491): undefined reference to `grpc_core::Fork::support_enabled_'
/usr/bin/ld: channel_arguments.cc:(.text+0x4b3): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text+0x666): undefined reference to `grpc_core::ExecCtx::Flush()'
/usr/bin/ld: channel_arguments.cc:(.text+0x685): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text+0x6c8): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text+0x842): undefined reference to `gpr_log'
/usr/bin/ld: channel_arguments.cc:(.text+0x983): undefined reference to `grpc_core::Fork::support_enabled_'
/usr/bin/ld: channel_arguments.cc:(.text+0x993): undefined reference to `grpc_core::Fork::DoDecExecCtxCount()'
/usr/bin/ld: channel_arguments.cc:(.text+0x9a1): undefined reference to `grpc_core::Fork::DoIncExecCtxCount()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::ChannelArguments(grpc::ChannelArguments const&)':
channel_arguments.cc:(.text+0xd62): undefined reference to `gpr_log'
/usr/bin/ld: channel_arguments.cc:(.text+0xe02): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::SetUserAgentPrefix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
channel_arguments.cc:(.text+0x1c17): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::SetResourceQuota(grpc::ResourceQuota const&)':
channel_arguments.cc:(.text+0x1ffc): undefined reference to `grpc_resource_quota_arg_vtable'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc_core::ExecCtx::~ExecCtx()':
channel_arguments.cc:(.text._ZN9grpc_core7ExecCtxD2Ev[_ZN9grpc_core7ExecCtxD5Ev]+0x21): undefined reference to `grpc_core::ExecCtx::Flush()'
/usr/bin/ld: channel_arguments.cc:(.text._ZN9grpc_core7ExecCtxD2Ev[_ZN9grpc_core7ExecCtxD5Ev]+0x3c): undefined reference to `grpc_core::ExecCtx::exec_ctx_'
/usr/bin/ld: channel_arguments.cc:(.text._ZN9grpc_core7ExecCtxD2Ev[_ZN9grpc_core7ExecCtxD5Ev]+0x73): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: channel_arguments.cc:(.text._ZN9grpc_core7ExecCtxD2Ev[_ZN9grpc_core7ExecCtxD5Ev]+0x93): undefined reference to `grpc_core::Fork::support_enabled_'
/usr/bin/ld: channel_arguments.cc:(.text._ZN9grpc_core7ExecCtxD2Ev[_ZN9grpc_core7ExecCtxD5Ev]+0x9f): undefined reference to `grpc_core::Fork::DoDecExecCtxCount()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::~ChannelArguments() [clone .cold]':
channel_arguments.cc:(.text.unlikely+0x1e): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_arguments.cc.o): in function `grpc::ChannelArguments::SetSocketMutator(grpc_socket_mutator*) [clone .cold]':
channel_arguments.cc:(.text.unlikely+0x9b): undefined reference to `grpc_core::Timestamp::thread_local_time_source_'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::~Channel()':
channel_cc.cc:(.text+0x18a): undefined reference to `grpc_channel_destroy'
/usr/bin/ld: channel_cc.cc:(.text+0x1de): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: channel_cc.cc:(.text+0x271): undefined reference to `grpc_iomgr_run_in_background()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::CallbackCQ()':
channel_cc.cc:(.text+0x393): undefined reference to `absl::lts_20220623::Mutex::Lock()'
/usr/bin/ld: channel_cc.cc:(.text+0x3a5): undefined reference to `grpc_iomgr_run_in_background()'
/usr/bin/ld: channel_cc.cc:(.text+0x497): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: channel_cc.cc:(.text+0x4b0): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::WaitForStateChangeImpl(grpc_connectivity_state, gpr_timespec)':
channel_cc.cc:(.text+0x69b): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: channel_cc.cc:(.text+0x6f2): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::GetLoadBalancingPolicyName[abi:cxx11]() const':
channel_cc.cc:(.text+0x906): undefined reference to `grpc_channel_get_info'
/usr/bin/ld: channel_cc.cc:(.text+0x963): undefined reference to `gpr_free'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::GetServiceConfigJSON[abi:cxx11]() const':
channel_cc.cc:(.text+0xaa6): undefined reference to `grpc_channel_get_info'
/usr/bin/ld: channel_cc.cc:(.text+0xb03): undefined reference to `gpr_free'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc::ClientContext*, grpc::CompletionQueue*, unsigned long)':
channel_cc.cc:(.text+0xcf5): undefined reference to `grpc_channel_create_registered_call'
/usr/bin/ld: channel_cc.cc:(.text+0xdc7): undefined reference to `grpc_channel_create_call'
/usr/bin/ld: channel_cc.cc:(.text+0xde3): undefined reference to `grpc_slice_unref'
/usr/bin/ld: channel_cc.cc:(.text+0xdfc): undefined reference to `grpc_slice_unref'
/usr/bin/ld: channel_cc.cc:(.text+0xe16): undefined reference to `grpc_census_call_set_context'
/usr/bin/ld: channel_cc.cc:(.text+0x10e6): undefined reference to `grpc_channel_create_call'
/usr/bin/ld: channel_cc.cc:(.text+0x1102): undefined reference to `grpc_slice_unref'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::RegisterMethod(char const*)':
channel_cc.cc:(.text+0xa8): undefined reference to `grpc_channel_register_call'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::GetState(bool)':
channel_cc.cc:(.text+0xbd): undefined reference to `grpc_channel_check_connectivity_state'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::NotifyOnStateChangeImpl(grpc_connectivity_state, gpr_timespec, grpc::CompletionQueue*, void*)':
channel_cc.cc:(.text+0x12d): undefined reference to `grpc_channel_watch_connectivity_state'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::experimental::ChannelResetConnectionBackoff(grpc::Channel*)':
channel_cc.cc:(.text+0xc09): undefined reference to `grpc_channel_reset_connect_backoff'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::CallbackCQ() [clone .cold]':
channel_cc.cc:(.text.unlikely+0x12): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: channel_cc.cc:(.text.unlikely+0x2f): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(channel_cc.cc.o): in function `grpc::Channel::WaitForStateChangeImpl(grpc_connectivity_state, gpr_timespec) [clone .cold]':
channel_cc.cc:(.text.unlikely+0x75): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::(anonymous namespace)::CallbackAlternativeCQ::Ref()::{lambda(void*)#1}::_FUN(void*)':
completion_queue_cc.cc:(.text+0x4b): undefined reference to `gpr_time_from_millis'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x5b): undefined reference to `gpr_now'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x6c): undefined reference to `gpr_time_add'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x79): undefined reference to `grpc_completion_queue_next'
/usr/bin/ld: completion_queue_cc.cc:(.text+0xab): undefined reference to `gpr_time_from_millis'
/usr/bin/ld: completion_queue_cc.cc:(.text+0xbb): undefined reference to `gpr_now'
/usr/bin/ld: completion_queue_cc.cc:(.text+0xcc): undefined reference to `gpr_time_add'
/usr/bin/ld: completion_queue_cc.cc:(.text+0xd7): undefined reference to `gpr_sleep_until'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::AsyncNextInternal(void**, bool*, gpr_timespec)':
completion_queue_cc.cc:(.text+0x198): undefined reference to `grpc_completion_queue_next'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::CompletionQueueTLSCache::~CompletionQueueTLSCache()':
completion_queue_cc.cc:(.text+0x256): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::CompletionQueueTLSCache::Flush(void**, bool*)':
completion_queue_cc.cc:(.text+0x29f): undefined reference to `grpc_completion_queue_thread_local_cache_flush'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::CallbackAlternativeCQ()':
completion_queue_cc.cc:(.text+0x321): undefined reference to `gpr_once_init'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x330): undefined reference to `absl::lts_20220623::Mutex::Lock()'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x353): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x426): undefined reference to `gpr_cpu_num_cores'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x4b2): undefined reference to `grpc_core::Thread::Thread(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x570): undefined reference to `grpc_core::Thread::Thread(char const*, void (*)(void*), void*, bool*, grpc_core::Thread::Options const&)'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x684): undefined reference to `gpr_log'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x712): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::ReleaseCallbackAlternativeCQ(grpc::CompletionQueue*)':
completion_queue_cc.cc:(.text+0x7a9): undefined reference to `absl::lts_20220623::Mutex::Lock()'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x80b): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: completion_queue_cc.cc:(.text+0x87c): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::CompletionQueueTLSCache::CompletionQueueTLSCache(grpc::CompletionQueue*)':
completion_queue_cc.cc:(.text+0x210): undefined reference to `grpc_completion_queue_thread_local_cache_init'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc_core::Thread::~Thread()':
completion_queue_cc.cc:(.text._ZN9grpc_core6ThreadD2Ev[_ZN9grpc_core6ThreadD5Ev]+0x3d): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::CallbackAlternativeCQ() [clone .cold]':
completion_queue_cc.cc:(.text.unlikely+0x11): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: completion_queue_cc.cc:(.text.unlikely+0x2b): undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(completion_queue_cc.cc.o): in function `grpc::CompletionQueue::ReleaseCallbackAlternativeCQ(grpc::CompletionQueue*) [clone .cold]':
completion_queue_cc.cc:(.text.unlikely+0x83): undefined reference to `absl::lts_20220623::Mutex::Unlock()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(client_interceptor.cc.o): in function `grpc::experimental::RegisterGlobalClientInterceptorFactory(grpc::experimental::ClientInterceptorFactoryInterface*)':
client_interceptor.cc:(.text+0x38): undefined reference to `gpr_log'
/usr/bin/ld: xxxx/my/proto/libmy_core.a(my.grpc.pb.cc.o): in function `grpc::CompletionQueue::~CompletionQueue()':
/usr/local/include/grpcpp/impl/codegen/completion_queue.h:119: undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: xxxx/my/proto/libmy_core.a(my.grpc.pb.cc.o): in function `grpc::CompletionQueue::CompletionQueue(grpc_completion_queue_attributes const&)':
/usr/local/include/grpcpp/impl/codegen/completion_queue.h:253: undefined reference to `absl::lts_20220623::Mutex::~Mutex()'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_new_with_user_data(void*, unsigned long, void (*)(void*), void*)':
core_codegen.cc:(.text+0x2ca): undefined reference to `grpc_slice_new_with_user_data'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_new_with_len(void*, unsigned long, void (*)(void*, unsigned long))':
core_codegen.cc:(.text+0x317): undefined reference to `grpc_slice_new_with_len'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_empty_slice()':
core_codegen.cc:(.text+0x35e): undefined reference to `grpc_empty_slice'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_malloc(unsigned long)':
core_codegen.cc:(.text+0x3b1): undefined reference to `grpc_slice_malloc'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_ref(grpc_slice)':
core_codegen.cc:(.text+0x41e): undefined reference to `grpc_slice_ref'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_split_tail(grpc_slice*, unsigned long)':
core_codegen.cc:(.text+0x474): undefined reference to `grpc_slice_split_tail'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_split_head(grpc_slice*, unsigned long)':
core_codegen.cc:(.text+0x4c4): undefined reference to `grpc_slice_split_head'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_sub(grpc_slice, unsigned long, unsigned long)':
core_codegen.cc:(.text+0x524): undefined reference to `grpc_slice_sub'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_from_static_buffer(void const*, unsigned long)':
core_codegen.cc:(.text+0x574): undefined reference to `grpc_slice_from_static_buffer'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_slice_from_copied_buffer(void const*, unsigned long)':
core_codegen.cc:(.text+0x5c4): undefined reference to `grpc_slice_from_copied_buffer'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::assert_fail(char const*, char const*, int)':
core_codegen.cc:(.text+0x67f): undefined reference to `gpr_log'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_factory_lookup(grpc_completion_queue_attributes const*)':
core_codegen.cc:(.text+0x28): undefined reference to `grpc_completion_queue_factory_lookup'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_create(grpc_completion_queue_factory const*, grpc_completion_queue_attributes const*, void*)':
core_codegen.cc:(.text+0x3e): undefined reference to `grpc_completion_queue_create'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_create_for_next(void*)':
core_codegen.cc:(.text+0x58): undefined reference to `grpc_completion_queue_create_for_next'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_create_for_pluck(void*)':
core_codegen.cc:(.text+0x68): undefined reference to `grpc_completion_queue_create_for_pluck'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_shutdown(grpc_completion_queue*)':
core_codegen.cc:(.text+0x78): undefined reference to `grpc_completion_queue_shutdown'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_destroy(grpc_completion_queue*)':
core_codegen.cc:(.text+0x88): undefined reference to `grpc_completion_queue_destroy'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_completion_queue_pluck(grpc_completion_queue*, void*, gpr_timespec, void*)':
core_codegen.cc:(.text+0xa4): undefined reference to `grpc_completion_queue_pluck'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_malloc(unsigned long)':
core_codegen.cc:(.text+0xb8): undefined reference to `gpr_malloc'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_free(void*)':
core_codegen.cc:(.text+0xc8): undefined reference to `gpr_free'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_init()':
core_codegen.cc:(.text+0xd5): undefined reference to `grpc_init'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::grpc_shutdown()':
core_codegen.cc:(.text+0xe5): undefined reference to `grpc_shutdown'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_mu_init(long*)':
core_codegen.cc:(.text+0xf8): undefined reference to `gpr_mu_init'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_mu_destroy(long*)':
core_codegen.cc:(.text+0x108): undefined reference to `gpr_mu_destroy'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_mu_lock(long*)':
core_codegen.cc:(.text+0x118): undefined reference to `gpr_mu_lock'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_mu_unlock(long*)':
core_codegen.cc:(.text+0x128): undefined reference to `gpr_mu_unlock'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function `grpc::CoreCodegen::gpr_cv_init(long*)':
core_codegen.cc:(.text+0x138): undefined reference to `gpr_cv_init'
/usr/bin/ld: /usr/local/lib/libgrpc++.a(core_codegen.cc.o): in function 
# there are more logs, but not enough space for SO question

Solution

  • For those who may run into the same issue, there is a conversation about this at https://github.com/grpc/grpc/issues/31449.