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 18.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.
  • B Offline
    B Offline
    blah900
    wrote on 5 Jan 2014, 17:46 last edited by
    #1

    Hi I am relatively new at this but I wanted to use Google's protobufs for my project.

    I am using Win7.

    So I used cygwin and did
    ./configure --enable-static --disable-shared - to create static lbirary.
    make - to make
    make check - all tests passed
    make install - no errors that I could see

    So once that happened I generated the pb file, which went fine without any problems using
    protoc.exe --cpp_out=. myproto.proto

    So after that I went and started a new Qt Widget project.
    I added existing files myproto.pb.cc and myproto.pb.h along with the config.h that was generated when I ran configure.

    This is what I have in my pro file. Qmake works fine with no error appearing.
    @#-------------------------------------------------

    Project created by QtCreator 2014-01-04T16:16:27

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = TestProto
    TEMPLATE = app

    SOURCES += main.cpp
    MainWindow.cpp
    Map/Tile.cpp
    Protobufs/myproto.pb.cc
    Map/TileTest.cpp

    HEADERS += MainWindow.h
    Map/Tile.h
    Protobufs/myproto.pb.h
    Map/TileTest.h
    config.h

    FORMS += MainWindow.ui

    LIBS += -LC:/cygwin64/usr/local/lib -lprotobuf

    INCLUDEPATH += C:/cygwin64/usr/local/include
    @

    However when I try to build it has the following error messages (put only 4 out of 200+):
    @error: undefined reference to google::protobuf::DescriptorPool::generated_pool()' error: undefined reference to google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
    error: undefined reference to google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' error: undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'@

    Any idea on what I am doing wrong?

    I have searched for the answer but other people seem to be able to compile their code fine when they do it like this.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Jan 2014, 21:25 last edited by
      #2

      Hi,

      Just a wild guess, are you using compatible compilers for all builds ?

      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
      • B Offline
        B Offline
        blah900
        wrote on 6 Jan 2014, 00:11 last edited by
        #3

        Wow, that worked!

        Once things have been compiled into an .exe, I don't need to carry around the protobuf library since it's static library right?

        V 1 Reply Last reply 22 Dec 2022, 08:06
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 6 Jan 2014, 08:18 last edited by
          #4

          That's correct yes

          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
          • B blah900
            6 Jan 2014, 00:11

            Wow, that worked!

            Once things have been compiled into an .exe, I don't need to carry around the protobuf library since it's static library right?

            V Offline
            V Offline
            VimHar
            wrote on 22 Dec 2022, 08:06 last edited by
            #5

            @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 1 Reply Last reply 22 Dec 2022, 08:09
            0
            • 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

                            JonBJ 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

                              JonBJ Offline
                              JonBJ Offline
                              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
                              • JonBJ 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 JonBJ 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)''

                                    JonBJ Offline
                                    JonBJ Offline
                                    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
                                    • JonBJ 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 JonBJ 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??

                                          JonBJ Offline
                                          JonBJ Offline
                                          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

                                          • Login

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