c++ error that namespace grpc don’t have member ProtoReflectionDescriptorDatabase in grpc


This Content is from Stack Overflow. Question asked by wtq

i write a simple client/server use grpc in c++.
i want to use the server reflection.the server has work normally。i use bloomrpc to check the server reflection and it is ok.
but i meet a problem in my own client.

#include <grpcpp/grpcpp.h>
int main(int argc,char **argv)
    std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel("localhost::50051", grpc::InsecureChannelCredentials());
    grpc::ProtoReflectionDescriptorDatabase reflection_db(channel);
    return 0;

it mention that namespace grpc don’t have member ProtoReflectionDescriptorDatabase.
why is that?
i refer to this document https://grpc.github.io/grpc/core/md_doc_server_reflection_tutorial.html.
and the client code is also from this document.
the CMakeLists.txt is as follows:

cmake_minimum_required(VERSION 3.0)


set(SRC_LIST main.cpp)

find_package(Threads REQUIRED)
find_package(protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)

add_executable(testclient ${SRC_LIST} )
target_link_libraries(testclient gRPC::grpc++ gRPC::grpc++_reflection) 


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?