Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Using google protobuf with Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Using google protobuf with Qt Creator

Scheduled Pinned Locked Moved 3rd Party Software
25 Posts 5 Posters 20.4k Views 1 Watching
  • 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.
  • V VimHar

    @jsulm

    LIBS += -LC:/vcpkg/installed/x64-windows/lib/ -llibprotobuf

    like this

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #8

    @VimHar said in Using google protobuf with Qt Creator:

    -llibprotobuf

    -lprotobuf
    

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

    V 1 Reply Last reply
    0
    • jsulmJ jsulm

      @VimHar said in Using google protobuf with Qt Creator:

      -llibprotobuf

      -lprotobuf
      
      V Offline
      V Offline
      VimHar
      wrote on last edited by VimHar
      #9

      @jsulm Have done that. It says
      :-1: error: cannot find -lprotobuf

      My files in lib folder are libprotobuf.lib , libprotobuf-lite.lib , libprotoc.lib

      jsulmJ 1 Reply Last reply
      0
      • V VimHar

        @jsulm Have done that. It says
        :-1: error: cannot find -lprotobuf

        My files in lib folder are libprotobuf.lib , libprotobuf-lite.lib , libprotoc.lib

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #10

        @VimHar On windows you need libprotobuf.lib to link at build time - do you have it?

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

        V 1 Reply Last reply
        0
        • jsulmJ jsulm

          @VimHar On windows you need libprotobuf.lib to link at build time - do you have it?

          V Offline
          V Offline
          VimHar
          wrote on last edited by VimHar
          #11

          @jsulm Yes as stated I have these files in lib folder of the path specified,
          libprotobuf.lib , libprotobuf-lite.lib , libprotoc.lib

          My .pro file

          QT += core gui

          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

          CONFIG += c++17

          INCLUDEPATH += C:\vcpkg\installed\x64-windows\include\

          LIBS += -LC:/vcpkg/installed/x64-windows/lib/ -lprotobuf

          SOURCES +=
          main.cpp
          mainwindow.cpp
          m.pb.cc

          HEADERS +=
          mainwindow.h
          m.pb.h

          FORMS +=
          mainwindow.ui

          jsulmJ 1 Reply Last reply
          0
          • V VimHar

            @jsulm Yes as stated I have these files in lib folder of the path specified,
            libprotobuf.lib , libprotobuf-lite.lib , libprotoc.lib

            My .pro file

            QT += core gui

            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

            CONFIG += c++17

            INCLUDEPATH += C:\vcpkg\installed\x64-windows\include\

            LIBS += -LC:/vcpkg/installed/x64-windows/lib/ -lprotobuf

            SOURCES +=
            main.cpp
            mainwindow.cpp
            m.pb.cc

            HEADERS +=
            mainwindow.h
            m.pb.h

            FORMS +=
            mainwindow.ui

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #12

            @VimHar said in Using google protobuf with Qt Creator:

            -lprotobuf

            Try

            -llibprotobuf.lib
            

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

            V 1 Reply Last reply
            0
            • jsulmJ jsulm

              @VimHar said in Using google protobuf with Qt Creator:

              -lprotobuf

              Try

              -llibprotobuf.lib
              
              V Offline
              V Offline
              VimHar
              wrote on last edited by
              #13

              @jsulm No same error. Cannot find llibprotouf.lib

              JonBJ 1 Reply Last reply
              0
              • V VimHar

                @jsulm No same error. Cannot find llibprotouf.lib

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

                @VimHar
                There have been inconsistencies in the spellings of what you have typed in your various posts. Why don't you try:

                LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib
                

                Please use copy & paste of above line. If you get error please copy & paste exact text back here.

                V 1 Reply Last reply
                0
                • JonBJ JonB

                  @VimHar
                  There have been inconsistencies in the spellings of what you have typed in your various posts. Why don't you try:

                  LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib
                  

                  Please use copy & paste of above line. If you get error please copy & paste exact text back here.

                  V Offline
                  V Offline
                  VimHar
                  wrote on last edited by
                  #15

                  @JonB said in Using google protobuf with Qt Creator:

                  LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib

                  QT += core gui

                  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                  CONFIG += c++17

                  INCLUDEPATH += C:\vcpkg\installed\x64-windows\include\

                  LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib

                  SOURCES +=
                  main.cpp
                  mainwindow.cpp
                  m.pb.cc

                  HEADERS +=
                  mainwindow.h
                  m.pb.h

                  FORMS +=
                  mainwindow.ui

                  Sorry for the same. Even then Im getting the same undefined error faced by the actual questioner.
                  i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)''

                  jsulmJ JonBJ 2 Replies Last reply
                  0
                  • V VimHar

                    @JonB said in Using google protobuf with Qt Creator:

                    LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib

                    QT += core gui

                    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                    CONFIG += c++17

                    INCLUDEPATH += C:\vcpkg\installed\x64-windows\include\

                    LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib

                    SOURCES +=
                    main.cpp
                    mainwindow.cpp
                    m.pb.cc

                    HEADERS +=
                    mainwindow.h
                    m.pb.h

                    FORMS +=
                    mainwindow.ui

                    Sorry for the same. Even then Im getting the same undefined error faced by the actual questioner.
                    i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)''

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #16

                    @VimHar Was the Protobuf lib built using same compiler? What compiler do you use to build your app?

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

                    1 Reply Last reply
                    0
                    • V VimHar

                      @JonB said in Using google protobuf with Qt Creator:

                      LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib

                      QT += core gui

                      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                      CONFIG += c++17

                      INCLUDEPATH += C:\vcpkg\installed\x64-windows\include\

                      LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib

                      SOURCES +=
                      main.cpp
                      mainwindow.cpp
                      m.pb.cc

                      HEADERS +=
                      mainwindow.h
                      m.pb.h

                      FORMS +=
                      mainwindow.ui

                      Sorry for the same. Even then Im getting the same undefined error faced by the actual questioner.
                      i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)''

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

                      @VimHar said in Using google protobuf with Qt Creator:

                      Even then Im getting the same undefined error faced by the actual questioner.
                      i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)''

                      Now I do not understand, because this is not the same error at all as you said you were having. You said you got one of:

                      . :-1: error: cannot find -lprotobuf
                      Cannot find llibprotouf.lib

                      These errors mean it could not find the library file to link with --- which is why I wanted to get you to type in the full path --- where the error now is that the library file is found, but you have an unresolved reference. Quite different kinds of error.

                      I think/suspect the lib file is being found but is the wrong version or built with the wrong compiler or something like that.... Please start by answering @jsulm's question with your best information.

                      V 1 Reply Last reply
                      1
                      • JonBJ JonB

                        @VimHar said in Using google protobuf with Qt Creator:

                        Even then Im getting the same undefined error faced by the actual questioner.
                        i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)''

                        Now I do not understand, because this is not the same error at all as you said you were having. You said you got one of:

                        . :-1: error: cannot find -lprotobuf
                        Cannot find llibprotouf.lib

                        These errors mean it could not find the library file to link with --- which is why I wanted to get you to type in the full path --- where the error now is that the library file is found, but you have an unresolved reference. Quite different kinds of error.

                        I think/suspect the lib file is being found but is the wrong version or built with the wrong compiler or something like that.... Please start by answering @jsulm's question with your best information.

                        V Offline
                        V Offline
                        VimHar
                        wrote on last edited by VimHar
                        #18

                        hey Thanks..JonB.. The actual intention of mine is the "undefined error" only.
                        Regarding compilers, I used vcpkg for installing protobuf and Qt uses MinGw64.

                        Is this the problem??

                        jsulmJ JonBJ 2 Replies Last reply
                        0
                        • V VimHar

                          hey Thanks..JonB.. The actual intention of mine is the "undefined error" only.
                          Regarding compilers, I used vcpkg for installing protobuf and Qt uses MinGw64.

                          Is this the problem??

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #19

                          @VimHar said in Using google protobuf with Qt Creator:

                          Is this the problem??

                          Probably.
                          There should be a linker warning in the build log.

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

                          1 Reply Last reply
                          1
                          • V VimHar

                            hey Thanks..JonB.. The actual intention of mine is the "undefined error" only.
                            Regarding compilers, I used vcpkg for installing protobuf and Qt uses MinGw64.

                            Is this the problem??

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

                            @VimHar said in Using google protobuf with Qt Creator:

                            I used vcpkg for installing protobuf and Qt uses MinGw64.

                            I don't know what "vcpkg" is (MSVC??) but it sounds like a different compiler/linker. MinGW library files end in .a not .lib, maybe that is the cause of the "cannot find library" messages? In any case you need to use the smae compiler/linker for everything.

                            1 Reply Last reply
                            1
                            • V Offline
                              V Offline
                              VimHar
                              wrote on last edited by VimHar
                              #21

                              Hey,.. Great. I have done re-installing protobuf using Msys following the steps below
                              https://stackoverflow.com/a/73287395/10432503

                              Now I can able to run using plain g++ command in the terminal.

                              But when I do the same in QT , the following error occurs
                              :-1: error: Dwarf Error: Can't find .debug_ranges section.

                              My .pro file
                              QT += core gui

                              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                              CONFIG += c++17

                              INCLUDEPATH += C:/protobuf-3.21.11/src

                              LIBS += -LC:/protobuf-3.21.11/src/.libs -lprotobuf

                              SOURCES +=
                              main.cpp
                              mainwindow.cpp
                              m.pb.cc

                              HEADERS +=
                              mainwindow.h
                              m.pb.h

                              FORMS +=
                              mainwindow.ui

                              Should I add anything more.?

                              1 Reply Last reply
                              0
                              • V Offline
                                V Offline
                                VimHar
                                wrote on last edited by
                                #22

                                Hey Jon,

                                Im also sharing you the compiler definitions.
                                7f048c43-9351-45d8-a16a-739fafa8d8da-image.png

                                Im using
                                e42d5a06-f656-4a9e-b4ed-a0159e1c52ff-image.png

                                The g++ command works smoothly. But I'm getting this new error when I compile using QT.
                                FYI, I have two MinGWs one inside QT folder and one inside Msys folder.

                                Am I missing any? :(

                                JonBJ 1 Reply Last reply
                                0
                                • V VimHar

                                  Hey Jon,

                                  Im also sharing you the compiler definitions.
                                  7f048c43-9351-45d8-a16a-739fafa8d8da-image.png

                                  Im using
                                  e42d5a06-f656-4a9e-b4ed-a0159e1c52ff-image.png

                                  The g++ command works smoothly. But I'm getting this new error when I compile using QT.
                                  FYI, I have two MinGWs one inside QT folder and one inside Msys folder.

                                  Am I missing any? :(

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

                                  @VimHar
                                  I know nothing about this area. ":-1: error: Dwarf Error: Can't find .debug_ranges section." implies to me you have incompatible compilers or incompatible options or something.

                                  1 Reply Last reply
                                  1
                                  • V Offline
                                    V Offline
                                    VimHar
                                    wrote on last edited by VimHar
                                    #24

                                    What you said is right. Thanks Jon. Reach out incase you got any. I will try.

                                    1 Reply Last reply
                                    0
                                    • V Offline
                                      V Offline
                                      VimHar
                                      wrote on last edited by
                                      #25

                                      d60e951b-d2ad-4c5c-90bb-acd5587fc90e-image.png

                                      Hey Can you help me how to enable the MSVC compiler , I couldnt choose it.

                                      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