OK, this was due to a misunderstanding of the output files produces by Bazel.
I have a proto file that defines a simple unary service. When I compile this using Bazel and the cc_grpc_library rule, it outputs an archive library and a shared object and prints these to the terminal. I was assuming that I just needed to pass this archive to my top level compilation flow but it seems that I need the archive AND all service.grpc.pb.{cc,h} and service.pb.{cc,h} files. On Monday, 28 November 2022 at 18:30:48 UTC Shareef Jalloq wrote: > Sorry, I fixed the missing reflection library, it's jus the > helloworld::Greeter::Service::Service() issues. But these are defined in > the auto-generated output of the protocol buffer compiler. > > On Monday, 28 November 2022 at 18:13:54 UTC Shareef Jalloq wrote: > >> Hi, >> >> I've been trying to integrate the simple C++ callback example into my >> application to make sure I can compile it successfully before implementing >> my full protocol. However, I'm getting linker errors and can't spot what I >> might have missed. >> >> I've really just copied the greeter_callback_server.cc contents and put >> it in my app. My linker settings look like: >> >> -lgrpc -lgrpc++ -lgpr -labsl_synchronization -lprotobuf >> -lgrpc_plugin_support -L/opt/grpc/v1.50.1/lib >> >> after having compiled and installed using CMake. >> >> The errors I'm seeing are: >> >> /usr/bin/ld: grpc_server.o: in function `GrpcServer::CreateServer()': >> grpc_server.cc:(.text+0x2e5): undefined reference to >> `grpc::reflection::InitProtoReflectionServerBuilderPlugin()' >> /usr/bin/ld: grpc_server.o: in function >> `helloworld::Greeter::WithCallbackMethod_SayHello<helloworld::Greeter::Service>::~WithCallbackMethod_SayHello()': >> grpc_server.cc:(.text._ZN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEED2Ev[_ZN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEED5Ev]+0xb): >> >> undefined reference to `helloworld::Greeter::Service::~Service()' >> /usr/bin/ld: grpc_server.o: in function >> `helloworld::Greeter::WithCallbackMethod_SayHello<helloworld::Greeter::Service>::WithCallbackMethod_SayHello()': >> grpc_server.cc:(.text._ZN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEEC2Ev[_ZN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEEC5Ev]+0x26): >> >> undefined reference to `helloworld::Greeter::Service::Service()' >> /usr/bin/ld: >> grpc_server.cc:(.text._ZN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEEC2Ev[_ZN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEEC5Ev]+0x1b1): >> >> undefined reference to `helloworld::Greeter::Service::~Service()' >> /usr/bin/ld: >> grpc_server.o:(.data.rel.ro._ZTIN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEEE[_ZTIN10helloworld7Greeter27WithCallbackMethod_SayHelloINS0_7ServiceEEE]+0x10): >> >> undefined reference to `typeinfo for helloworld::Greeter::Service' >> collect2: error: ld returned 1 exit status >> > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/5b56594c-db08-4c9d-ade7-91f4f2c2f561n%40googlegroups.com.