Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problems linking for Android when using QT's gRPC generator.
Forum Updated to NodeBB v4.3 + New Features

Problems linking for Android when using QT's gRPC generator.

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 341 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jarle
    wrote on last edited by
    #1

    I have a toy project where I simply implement a client for googles "Route Guide" example using QT 6.7.1 and QML. The program works when I Compile for desktop. When I compile for Android/x86_64, I get a link error for the gRPC library.

    I'm using qt_add_protobuf and qt_add_grpc in the projects CMakeLists.txt.

    [15/42 11.1/sec] Building CXX object src/qt_client/CMakeFiles/GrpcClient.dir/GrpcClient_autogen/mocs_compilation.cpp.o
    [16/42 11.8/sec] Building CXX object src/qt_client/CMakeFiles/GrpcClient.dir/route_guide_client.grpc.qpb.cpp.o
    [17/42 12.2/sec] Linking CXX shared library src/qt_client/libGrpcClient_x86_64.so
    FAILED: src/qt_client/libGrpcClient_x86_64.so 
    

    I have a similar error in a real project if I try to compile for Android.

    Is this a bug, or do I need to do something special in the CMake files to make gRPC work for Android.

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I would say you first have to compile the gRPC library for Android.
      You also did not post the actual error.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      0
      • jsulmJ jsulm

        I would say you first have to compile the gRPC library for Android.
        You also did not post the actual error.

        J Offline
        J Offline
        jarle
        wrote on last edited by
        #3

        @jsulm Thank you. Looking deeper into the actual error message show that the generated protobuf library was not automatically linked with the generated gRPC library when compiling for Android.

        Adding this to the CMakeList.txt fixed that problem.

        # Existing code
        qt_add_protobuf(RouteGuideLib
            QML
            QML_URI routeguide.pb
            PROTO_FILES ${protofile}
        )
        
        qt_add_grpc(GrpcClient CLIENT
            PROTO_FILES ${protofile}
        )
        
        # added to fix the problem
        
        target_link_libraries(GrpcClient
            PRIVATE
            RouteGuideLib
            Qt6::Core
            Qt6::Protobuf
            Qt6::Grpc
        )
        
        
        1 Reply Last reply
        1
        • J jarle has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved