Search code examples
c++grpcconan

Conan and gRPC: Undefined references to various `gpr_` symbols


This is an issue with using gRPC with Conan in my project. In short, I have a gRPC based project, and my dependencies are:

    requires = (
        "predictions-algorithms/15.16.51@navassist/testing",
        "grpc/1.20.0@inexorgame/stable",
        "protobuf/3.6.1@bincrafters/stable",
        "protoc_installer/3.6.1@bincrafters/stable"
    )

However, at the end of the linking process of the project, a bunch of messages appear about undefined references to various gpr_* symbols in libgrpc.a.

I checked with readelf -Ws my/package/path/to/libgrpc.a | grep gpr_(some symbol), and, sure enough, all those symbols are undefined in there.

I also opened the issue at the repository of gRPC package I use above.

No idea what to do next... Any help is welcome.


Solution

  • So, the problem was that I was linking against libgrpc, but not against its dependencies!

    Eventually, I modified my CMakeLists.txt to look like (don't ask me why it wasn't like that from the start...):

    target_link_libraries(${PROJECT_NAME}
        ${CONAN_LIBS}
    )
    

    And then it built sucessfully.