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
QtWS25 Last Chance

Using google protobuf with Qt Creator

Scheduled Pinned Locked Moved 3rd Party Software
25 Posts 5 Posters 18.3k 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.
  • V VimHar
    22 Dec 2022, 08:06

    @blah900 hey. What have you done that made things work. I have installed protobuf using vcpkg and pointing to the static library same as you did in windows.

    Except lptotobuf im using llibprotouf. Still facing the undefined erro.

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 22 Dec 2022, 08:09 last edited by
    #6

    @VimHar said in Using google protobuf with Qt Creator:

    Except lptotobuf im using llibprotouf

    How do you link libprotobuf?

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

    V 1 Reply Last reply 22 Dec 2022, 09:10
    0
    • J jsulm
      22 Dec 2022, 08:09

      @VimHar said in Using google protobuf with Qt Creator:

      Except lptotobuf im using llibprotouf

      How do you link libprotobuf?

      V Offline
      V Offline
      VimHar
      wrote on 22 Dec 2022, 09:10 last edited by
      #7

      @jsulm

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

      like this

      J 1 Reply Last reply 22 Dec 2022, 09:12
      0
      • V VimHar
        22 Dec 2022, 09:10

        @jsulm

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

        like this

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 22 Dec 2022, 09:12 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 22 Dec 2022, 09:23
        0
        • J jsulm
          22 Dec 2022, 09:12

          @VimHar said in Using google protobuf with Qt Creator:

          -llibprotobuf

          -lprotobuf
          
          V Offline
          V Offline
          VimHar
          wrote on 22 Dec 2022, 09:23 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

          J 1 Reply Last reply 22 Dec 2022, 09:28
          0
          • V VimHar
            22 Dec 2022, 09:23

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

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

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 22 Dec 2022, 09:28 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 22 Dec 2022, 09:35
            0
            • J jsulm
              22 Dec 2022, 09:28

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

              V Offline
              V Offline
              VimHar
              wrote on 22 Dec 2022, 09:35 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

              J 1 Reply Last reply 22 Dec 2022, 09:51
              0
              • V VimHar
                22 Dec 2022, 09:35

                @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

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 22 Dec 2022, 09:51 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 22 Dec 2022, 14:56
                0
                • J jsulm
                  22 Dec 2022, 09:51

                  @VimHar said in Using google protobuf with Qt Creator:

                  -lprotobuf

                  Try

                  -llibprotobuf.lib
                  
                  V Offline
                  V Offline
                  VimHar
                  wrote on 22 Dec 2022, 14:56 last edited by
                  #13

                  @jsulm No same error. Cannot find llibprotouf.lib

                  J 1 Reply Last reply 22 Dec 2022, 18:47
                  0
                  • V VimHar
                    22 Dec 2022, 14:56

                    @jsulm No same error. Cannot find llibprotouf.lib

                    J Online
                    J Online
                    JonB
                    wrote on 22 Dec 2022, 18:47 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 23 Dec 2022, 07:23
                    0
                    • J JonB
                      22 Dec 2022, 18:47

                      @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 23 Dec 2022, 07:23 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)''

                      J J 2 Replies Last reply 23 Dec 2022, 07:50
                      0
                      • V VimHar
                        23 Dec 2022, 07:23

                        @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)''

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 23 Dec 2022, 07:50 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
                          23 Dec 2022, 07:23

                          @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)''

                          J Online
                          J Online
                          JonB
                          wrote on 23 Dec 2022, 08:59 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 23 Dec 2022, 09:16
                          1
                          • J JonB
                            23 Dec 2022, 08:59

                            @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 23 Dec 2022, 09:16 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??

                            J J 2 Replies Last reply 23 Dec 2022, 09:18
                            0
                            • V VimHar
                              23 Dec 2022, 09:16

                              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??

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 23 Dec 2022, 09:18 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
                                23 Dec 2022, 09:16

                                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??

                                J Online
                                J Online
                                JonB
                                wrote on 23 Dec 2022, 09:27 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 23 Dec 2022, 10:40 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 23 Dec 2022, 11:59 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? :(

                                    J 1 Reply Last reply 23 Dec 2022, 12:04
                                    0
                                    • V VimHar
                                      23 Dec 2022, 11:59

                                      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? :(

                                      J Online
                                      J Online
                                      JonB
                                      wrote on 23 Dec 2022, 12:04 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 23 Dec 2022, 16:44 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 26 Dec 2022, 07:04 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

                                          15/25

                                          23 Dec 2022, 07:23

                                          • Login

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