Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. GRPC helloworld server "undefined references"
QtWS25 Last Chance

GRPC helloworld server "undefined references"

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
grpcserverc++11
8 Posts 3 Posters 2.4k 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.
  • N Offline
    N Offline
    NikoBir
    wrote on last edited by
    #1

    Hello everyone !

    I want to design a gRPC server on Qt. So, I took the helloword program on grpc website and I linked it with Qt.
    But this code exeample didn't work :

    e28db5e3-a1d8-42f9-9be8-a22401fd3757-image.png

    I use :

    Os : Debian 9
    Qt : 5.13.2
    Protoc : 3.19.4

    My pro file :

    QT -= gui
    #QT += protobuf grpc core
    
    CONFIG += c++11 console
    CONFIG -= app_bundle
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    INCLUDEPATH += \
        /home/name/.local/include/ \
        /home/name/.local/lib/ \
    
    LIBS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`
            -pthread
            -lgrpc++_reflection
            -ldl
    
    SOURCES += \
        greeter_server.cc \
        helloworld.grpc.pb.cc \
        helloworld.pb.cc
    
    HEADERS += \
        helloworld.grpc.pb.h \
        helloworld.pb.h
    
    DISTFILES += \
        helloworld.proto
    
    

    I have no idea how to solve this issue.
    I really thank you in advance for your help !

    JonBJ 1 Reply Last reply
    0
    • N NikoBir

      Hello everyone !

      I want to design a gRPC server on Qt. So, I took the helloword program on grpc website and I linked it with Qt.
      But this code exeample didn't work :

      e28db5e3-a1d8-42f9-9be8-a22401fd3757-image.png

      I use :

      Os : Debian 9
      Qt : 5.13.2
      Protoc : 3.19.4

      My pro file :

      QT -= gui
      #QT += protobuf grpc core
      
      CONFIG += c++11 console
      CONFIG -= app_bundle
      
      # The following define makes your compiler emit warnings if you use
      # any Qt feature that has been marked deprecated (the exact warnings
      # depend on your compiler). Please consult the documentation of the
      # deprecated API in order to know how to port your code away from it.
      DEFINES += QT_DEPRECATED_WARNINGS
      
      # You can also make your code fail to compile if it uses deprecated APIs.
      # In order to do so, uncomment the following line.
      # You can also select to disable deprecated APIs only up to a certain version of Qt.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      INCLUDEPATH += \
          /home/name/.local/include/ \
          /home/name/.local/lib/ \
      
      LIBS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`
              -pthread
              -lgrpc++_reflection
              -ldl
      
      SOURCES += \
          greeter_server.cc \
          helloworld.grpc.pb.cc \
          helloworld.pb.cc
      
      HEADERS += \
          helloworld.grpc.pb.h \
          helloworld.pb.h
      
      DISTFILES += \
          helloworld.proto
      
      

      I have no idea how to solve this issue.
      I really thank you in advance for your help !

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @NikoBir said in GRPC helloworld server "undefined references":

      pkg-config --libs protobuf grpc++

      The output shows missing external references to grpc functions. Have you checked just what the pkg-config command above returns for use into the LIBS variable? Is that syntactically correct, and is it enough together with -lgrpc++_reflection everything needed? Have a look at the complete g++ link line as it is generated and issued fro Creator.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Your LIBS looks wrong on several levels. It's missing backslashes since you made it multiline and I do not remember that syntax for retrieving something.

        qmake has support for pkg-config so you should rather use that.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • N Offline
          N Offline
          NikoBir
          wrote on last edited by
          #4

          Thanks both of you for your indication !
          Indeed, it was the pkg-config (that didn't return the grpc.pc file) and my libs in LIBS.
          So, I deleted the useless libs and I add in the PKG_CONFIG_PATH, the path to the grpc.pc lib.

          Now, my pro file is :

          QT -= gui
          #QT += protobuf grpc core
          
          CONFIG += c++11 console
          CONFIG -= app_bundle
          
          # The following define makes your compiler emit warnings if you use
          # any Qt feature that has been marked deprecated (the exact warnings
          # depend on your compiler). Please consult the documentation of the
          # deprecated API in order to know how to port your code away from it.
          DEFINES += QT_DEPRECATED_WARNINGS
          
          # You can also make your code fail to compile if it uses deprecated APIs.
          # In order to do so, uncomment the following line.
          # You can also select to disable deprecated APIs only up to a certain version of Qt.
          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
          
          INCLUDEPATH += \
              /home/name/.local/include/ \
              /home/name/.local/lib/ \
          
          LIBS += -L/usr/local/lib `pkg-config --libs grpc++`
          
          SOURCES += \
              greeter_server.cc \
              helloworld.grpc.pb.cc \
              helloworld.pb.cc
          
          HEADERS += \
              helloworld.grpc.pb.h \
              helloworld.pb.h
          
          DISTFILES += \
              helloworld.proto
          
          

          After correcting this issue, I have this error on the output terminal :

          error while loading shared libraries: libgrpc++.so.1.45: cannot open shared object file: No such file or directory
          

          So, after some research, I followed this advice :

          https://forum.qt.io/topic/58963/error-while-loading-shared-libraries-cannot-open-shared-object-file-no-such-file-or-directory/3

          but it was ineffective....

          I tested to add in the pro file :

          QMAKE_LFLAGS += -Wl,-rpath,"path_to_ibgrpc++.so.1.45"
          

          Do you know how to resolve this issue ?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Where is that library located in your machine ?

            As an alternative, you can set the LD_LIBRARY_PATH environment variable and add that folder to it.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NikoBir
              wrote on last edited by
              #6

              @SGaist said in GRPC helloworld server "undefined references":

              LD_LIBRARY_PATH

              Thanks for your answer !

              The library is located in "/home/name/.local/lib/libgrpc++.so.1.45".
              I tested your advice, I addes the directory path in my bashrc :
              export LD_LIBRARY_PATH="/home/edf/.local/lib/"

              And I updated it.

              But, I have the same issue :/

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Are you sure your project picked it up ?
                Check the Run part of the project panel.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  NikoBir
                  wrote on last edited by
                  #8

                  Nevermind ! It worked !!!!!!! Thank you !!!

                  1 Reply Last reply
                  0

                  • Login

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