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. Problem including Protobuf v3.x.x with Qt creator

Problem including Protobuf v3.x.x with Qt creator

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
5 Posts 2 Posters 5.0k 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.
  • S Offline
    S Offline
    SondreHoglund
    wrote on last edited by
    #1

    Hey guys,

    I've created a console application using Qt creator 4.2.1 and protobuf v.3.2.0. The application communicates with a TCP server and uses protobuf for serialization. This program works perfectly.

    Now I'm trying to make a GUI application with the same protobuf library. The program compiles and builds, but when I try to run the GUI, it complains about wrong version of protobuf. It seems like Qt comes prebuilt with protobuf v.2.6.1. Is this true? And how do I change the version to 3.2.0?

    The protobuf library is compiled from source as described here: https://github.com/google/protobuf/tree/master/src

    Below is a snapshot of the error message and the two .pro files

    Here is a link to a forum post with the same problem (but no solution): https://github.com/google/protobuf/issues/2979

    Best regards
    Sondre

    Error message when running in debug

    [libprotobuf FATAL google/protobuf/stubs/common.cc:78] This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.1.0).  Contact the program author for an update.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "/build/mir-pkdHET/mir-0.21.0+16.04.20160330/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
    terminate called after throwing an instance of 'google::protobuf::FatalException'
      what():  This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.1.0).  Contact the program author for an update.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "/build/mir-pkdHET/mir-0.21.0+16.04.20160330/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
    

    Application .pro file

    #-------------------------------------------------
    #
    # Project created by QtCreator 2017-03-20T15:26:58
    #
    #-------------------------------------------------
    
    QT       += core
    
    QT       -= gui
    
    TARGET = RobotHandler
    CONFIG   += console
    CONFIG   -= app_bundle
    
    TEMPLATE = app
    
    
    SOURCES += \
        <Source files here>
    
    HEADERS += \
        <Header files here>
    
    INCLUDEPATH += \
       <Include paths here>
    
    LIBS += \
        -L/usr/local/bin -lboost_system -lboost_thread -lprotobuf \
        -lrt
    
    QMAKE_CXXFLAGS += -std=c++11
    

    GUI .pro file

    TEMPLATE = app
    
    QT += qml quick \
        testlib
    unix{
            \
            webengine
        }
    
    SOURCES += \
        <Source files here>
    
    HEADERS += \
        <Header files here>
    
    INCLUDEPATH += \
       <Include paths here>
    
    RESOURCES += qml.qrc \
                $$FileURL
    
    FileURL = $$files(Imports/ViewVariables/*)
    
    message(File URL: $$FileURL)
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH = $$PWD/Imports
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as 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 you use 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
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    LIBS += \
        -L/usr/local/bin -lprotobuf \
        -lrt
    
    
    QMAKE_CXXFLAGS += -std=c++11
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, Qt doesn't use protobuf at all but QtWebEngine's backend does so there might be something to look up there.

      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
      • S Offline
        S Offline
        SondreHoglund
        wrote on last edited by
        #3

        Hi and thank you for the reply!

        I think you are correct, the QtWebengine uses protobuf. I tried to remove all includes to the module, e.g. QT += webengine, in the project file and all source and header files. However, i did not solve the problem. I suspect that the module is still linked to the program. Is it a way to permanently delete the QtWebengine module? I'm using Ubuntu 16.04 LTS

        Sondre

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

          Did you re-run qmake after removing the `QT += webengine" line ?

          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
          • S Offline
            S Offline
            SondreHoglund
            wrote on last edited by
            #5

            Yes, I did re-run qmake after the changes. I think I will try to make a new project and only import the essentials of the protobuf program to see if that will run.

            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