Skip to content

link grpcclient_static error. undefined reference to grpc #843

@weizhenhuan

Description

@weizhenhuan

I write a code with tritionserver cpp client, and then compile it using CMAKE:

add_executable(main main.cpp)
target_link_libraries(main PUBLIC grpcclient_static ${TORCH_LIBRARIES})

I find that in your example/simple_grpc_infer_client.cpp and it's CMAKE file,it only links grpcclient_static:

  #
  # simple_grpc_infer_client
  #
  add_executable(simple_grpc_infer_client simple_grpc_infer_client.cc)
  target_link_libraries(
    simple_grpc_infer_client
    PRIVATE
      grpcclient_static
  )

But when I compile my code, it gives the following error:

/usr/bin/ld: grpc_client.cc:(.text+0x1fd3): undefined reference to `grpc::ChannelArguments::SetInt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: grpc_client.cc:(.text+0x2152): undefined reference to `grpc::SslCredentials(grpc::SslCredentialsOptions const&)'
/usr/bin/ld: grpc_client.cc:(.text+0x2255): undefined reference to `grpc::CreateCustomChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc::ChannelCredentials> const&, grpc::ChannelArguments const&)'
/usr/bin/ld: grpc_client.cc:(.text+0x2448): undefined reference to `grpc::ChannelArguments::~ChannelArguments()'
/usr/bin/ld: grpc_client.cc:(.text+0x24b1): undefined reference to `grpc::InsecureChannelCredentials()'
/usr/bin/ld: /root/serving_tools/my_repo/lib/libgrpcclient_static.a(grpc_client.cc.o): in function `triton::client::InferenceServerGrpcClient::AsyncTransfer()':
grpc_client.cc:(.text+0x4423): undefined reference to `gpr_inf_future'
/usr/bin/ld: grpc_client.cc:(.text+0x443d): undefined reference to `grpc::CompletionQueue::AsyncNextInternal(void**, bool*, gpr_timespec)'
/usr/bin/ld: /root/serving_tools/my_repo/lib/libgrpcclient_static.a(grpc_client.cc.o): in function `triton::client::InferenceServerGrpcClient::AsyncStreamTransfer()':
grpc_client.cc:(.text+0x4da9): undefined reference to `gpr_inf_future'
/usr/bin/ld: grpc_client.cc:(.text+0x4dc4): undefined reference to `grpc_completion_queue_pluck'
/usr/bin/ld: grpc_client.cc:(.text+0x4fa5): undefined reference to `grpc_call_unref'
/usr/bin/ld: grpc_client.cc:(.text+0x5031): undefined reference to `grpc_byte_buffer_destroy'
/usr/bin/ld: grpc_client.cc:(.text+0x51f9): undefined reference to `grpc_byte_buffer_destroy'
/usr/bin/ld: grpc_client.cc:(.text+0x5339): undefined reference to `gpr_assertion_failed'
/usr/bin/ld: grpc_client.cc:(.text+0x5351): undefined reference to `grpc_call_unref'
/usr/bin/ld: grpc_client.cc:(.text+0x535f): undefined reference to `grpc_completion_queue_shutdown'
/usr/bin/ld: grpc_client.cc:(.text+0x53af): undefined reference to `gpr_assertion_failed'
/usr/bin/ld: grpc_client.cc:(.text+0x54a9): undefined reference to `gpr_assertion_failed'
/usr/bin/ld: grpc_client.cc:(.text+0x54c1): undefined reference to `gpr_assertion_failed'
/usr/bin/ld: grpc_client.cc:(.text+0x56db): undefined reference to `grpc_empty_slice'
/usr/bin/ld: grpc_client.cc:(.text+0x5712): undefined reference to `gpr_inf_future'
/usr/bin/ld: grpc_client.cc:(.text+0x5732): undefined reference to `grpc_completion_queue_pluck'
/usr/bin/ld: grpc_client.cc:(.text+0x57f6): undefined reference to `grpc_call_unref'
/usr/bin/ld: grpc_client.cc:(.text+0x5891): undefined reference to `grpc_call_unref'
/usr/bin/ld: grpc_client.cc:(.text+0x589f): undefined reference to `grpc_completion_queue_shutdown'
/usr/bin/ld: grpc_client.cc:(.text+0x590c): undefined reference to `gpr_assertion_failed'
/usr/bin/ld: grpc_client.cc:(.text+0x5924): undefined reference to `gpr_assertion_failed'
/usr/bin/ld: /root/serving_tools/my_repo/lib/libgrpcclient_static.a(grpc_client.cc.o): in function `triton::client::InferenceServerGrpcClient::IsServerLive(bool*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, unsigned long)':
grpc_client.cc:(.text+0x5a63): undefined reference to `grpc::ClientContext::ClientContext()'
/usr/bin/ld: grpc_client.cc:(.text+0x5a8c): undefined reference to `grpc::ClientContext::AddMetadata(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: grpc_client.cc:(.text+0x5b39): undefined reference to `grpc::ClientContext::~ClientContext()'

How to fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions