Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QTAndroid protobuf with QT creator
Qt 6.11 is out! See what's new in the release blog

QTAndroid protobuf with QT creator

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
20 Posts 3 Posters 4.3k Views 3 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.
  • SGaistS SGaist

    Hi and welcome to devnet,

    What exact error are you getting ?

    Did you try to build your project for your desktop machine ?

    Can you provide a minimal example project that people can attempt to build ?

    A Offline
    A Offline
    AMOL
    wrote on last edited by AMOL
    #3

    @sgaist hi and thank you for your response ,
    Actully I am trying to build my project for android phones (QTAndroid),
    My main Question is how to compile my .proto file for QTAndroid which gives .pb.cc and .pb.h in return
    I followed this link :
    https://github.com/protocolbuffers/protobuf/issues/5279

    after creating source tree I run below command to generate pb.cc and pb.h :
    ./protoc --cpp_out=./ myfile.proto

    but protoc file is not generating pb.cc and pb.h file.
    '

    My proto file code is given below:

    syntax = "proto2";

    package DOP;

    // Defines request that a tag/anchor may receive via UART or BT SPP
    enum ReqType {
    DFUMODE = 0; // Device must switch to DFU mode and reset
    SETUWBCFG = 1; // Set UWB network configuration parameters
    GETUWBCFG = 2; // Get current UWB network configuration parameters
    }

    // Defines types of responses to a request message
    enum RespType {
    ACK = 0; // ACK the successfull execution of a request
    NACK = 1; // Request was not executed
    RESPUWBCFG = 2; // Current UWB configuraion data
    }

    message Request {
    required uint32 req_type = 1; // Must be one of ReqType
    required uint32 req_ID = 2; // A number that would help the requesting side to indentify the reply later
    }

    message Response {
    required uint32 resp_type = 1; // Must be one of RespType
    required uint32 req_ID = 2; // The ID of the request to which we are replying

    // TODO: Add field for response parameters (like UWB configuration)

    }

    message Cycle {

    message Imu {
      required uint32 x = 1;	   
      required uint32 y = 2;
      required uint32 z = 3;
    }
    
    message Tag {
      required uint32 tagid     = 1;   // ID of the Tag which replied to the corresponding Anchor (current Tag). Number must be unique inside the network - 65536 max number of tags.
      required uint32 tof1      = 2;   // Time-of-flight from the corresponding Anchor to the current Tag, calculated during tsync1 and tsync2 slots accordingly. In in uS.
      required uint32 tof2      = 3;	 
    
      optional uint32 vbat      = 4;   // Battery voltage, 6bit, 25mV resolution, range between 2.650 V 4.250 V
      optional uint32 rssi      = 5;   // P46: DW1000 User Manual 2.03. Practical range -99...-67 dBm per  0.5dBm  
      optional uint32 sensor    = 6;   // Data from internal sensors, For pressure sensor - Range 0 to 1.28bar steps 0.02bar
      optional Imu 	  acc_data  = 7;   // Linear x,y, z acceleration from the Tag IMU 
      optional Imu	  gyro_data = 8;   // x,y, z data from the Tag IMU
      optional Imu 	  mag_data  = 9;   // 
      	
    }
    
    // Data collected by an Anchor
    message Anchor {
      required uint32 anchorid  = 1;   // ID of the Anchor which polled the Tag whos data are included in this message (current Anchor).
      required Tag tag_data     = 2;
    }
    
    required uint32 cycleid   = 1;   // ID of the current offload cycle. Wraps up to 0 when reaching the maximum.
    repeated Anchor anc_data  = 2;
    

    }

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

      One thing you can to is install the protobuf compiler package from your distribution and use that one. It will generate the files that you can then use for your project.

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

        I used protobuf but it is for Windows or Linux not for Android I want to cross compile it with Android then I can us it

        Pablo J. RoginaP 2 Replies Last reply
        0
        • A AMOL

          I used protobuf but it is for Windows or Linux not for Android I want to cross compile it with Android then I can us it

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #6

          @amol said in QTAndroid protobuf with QT creator:

          I want to cross compile it with Android then I can us it

          From the issue you pointed before, have you check this comment? It says it succeeded, and it describes all the tool versions for its environment (Clang, NDK, Qt, etc.)

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          A 1 Reply Last reply
          0
          • Pablo J. RoginaP Pablo J. Rogina

            @amol said in QTAndroid protobuf with QT creator:

            I want to cross compile it with Android then I can us it

            From the issue you pointed before, have you check this comment? It says it succeeded, and it describes all the tool versions for its environment (Clang, NDK, Qt, etc.)

            A Offline
            A Offline
            AMOL
            wrote on last edited by
            #7

            @pablo-j-rogina yes I used it but it's for clang I want for armabi-7

            Pablo J. RoginaP 1 Reply Last reply
            0
            • A AMOL

              @pablo-j-rogina yes I used it but it's for clang I want for armabi-7

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #8

              @amol said in QTAndroid protobuf with QT creator:

              it's for clang I want for armabi-7

              It looks you're mixing things up.

              Clang is a compiler (tool) while armabi-7 is a processor architecture (platform)
              A compiler creates an executable program for a particular platform.

              As you can see from that comment, Clang should allow you to build the required protobuf file(s) for your platform

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AMOL
                wrote on last edited by AMOL
                #9

                Ohh, then after building this I get protoc file from which I can make pb.cc and pb.h file but that protoc file gives error as excutable format error

                If you have any steps for how to make protoc for Android then please provide.

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

                  protoc just generate files in the programming language you choose. There's nothing special here, as I already suggested, install the protoc compiler from your distribution and generate the file with 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
                  • A Offline
                    A Offline
                    AMOL
                    wrote on last edited by AMOL
                    #11

                    Ok but issue then issue is after creating my pb.cc and pb.h file and added to qt creator is gives error as undefined reference to Google protobuf
                    Then can anyone provide steps for adding protobuf .so files and pb.cc pb.h files to qt creator and then run on Android

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

                      Did you add the

                      LIBS += 
                      

                      statement in your .pro file to link to the library ?

                      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
                      • A Offline
                        A Offline
                        AMOL
                        wrote on last edited by
                        #13

                        @sgaist said in QTAndroid protobuf with QT creator:

                        LIBS +=

                        My proto file look like this:

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

                        Project created by QtCreator 2016-03-22T07:38:29

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

                        QT += core gui bluetooth
                        CONFIG += c++11

                        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                        TARGET = BLETester
                        TEMPLATE = app

                        SOURCES += main.cpp
                        acp.pb.cc
                        dfuservice.cpp
                        mainwindow.cpp
                        bleinterface.cpp
                        utils.cpp

                        HEADERS += mainwindow.h
                        acp.pb.h
                        bleinterface.h
                        dfuservice.h
                        lib-qt-qml-tricks/src/qqmlhelpers.h
                        lib-qt-qml-tricks/src/qqmlhelpers.h
                        utils.h

                        FORMS += mainwindow.ui

                        win32:INCLUDEPATH += "$$PWD\google"

                        RESOURCES +=
                        resources.qrc

                        android{
                        INCLUDEPATH += F:\QT_android\compile\protobuf-3.9.1\src
                        LIBS += -L"F:\QT_android\compile\protobuf-3.9.1\src\protobuff_android"
                        -lprotobuf
                        -lprotobuf-lite
                        -lprotoc
                        }

                        Turn off ALL warning for the project

                        win32:CONFIG += warn_off

                        contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
                        ANDROID_EXTRA_LIBS =
                        $$PWD/../protobuf_android/libprotobuf.so
                        $$PWD/../protobuf_android/libprotobuf-lite.so
                        $$PWD/../protobuf_android/libprotoc.so
                        }

                        DISTFILES +=
                        acp.proto

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

                          Are you sure you have built protobuf for the correct architecture ? 32 vs 64 bit for example ?

                          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
                          • A Offline
                            A Offline
                            AMOL
                            wrote on last edited by
                            #15

                            @sgaist said in QTAndroid protobuf with QT creator:

                            distribution

                            @sgaist said in QTAndroid protobuf with QT creator:

                            protoc just generate files in the programming language you choose. There's nothing special here, as I already suggested, install the protoc compiler from your distribution and generate the file with it.

                            yes
                            as you said, i have installed protobuf compiler on Linux 64 bit and from that only I am generating pb.cc and pb.h files

                            Is that correct?

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              AMOL
                              wrote on last edited by
                              #16

                              @SGaist any comment on this???

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                AMOL
                                wrote on last edited by AMOL
                                #17

                                After compiling from protobuf-cpp-3.9.1 and adding pb.cc and pb.h to project I get this error
                                0_1567683866738_a8f75ad0-3bfc-4f60-bcb5-f433b61fe52f-image.png

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

                                  Start by just building the protobuf related files so you ensure that you have that stuff working correctly. I would even start first by building for your desktop OS. That way you ensure that this part is working correctly before going forward with Android.

                                  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
                                  • A Offline
                                    A Offline
                                    AMOL
                                    wrote on last edited by
                                    #19

                                    Yes, This application is hybrid application (ios,android and windows)
                                    for windows desktop application protobuf is working correctly without error,
                                    but when I change my kit to android then it gives above error

                                    1 Reply Last reply
                                    0
                                    • A AMOL

                                      I used protobuf but it is for Windows or Linux not for Android I want to cross compile it with Android then I can us it

                                      Pablo J. RoginaP Offline
                                      Pablo J. RoginaP Offline
                                      Pablo J. Rogina
                                      wrote on last edited by
                                      #20

                                      @amol said in QTAndroid protobuf with QT creator:

                                      I used protobuf but it is for Windows or Linux

                                      Ok, so you're somehow experienced with that technology.

                                      For me that I'm not, could you please explain how to use protobuf in a general way, and I guess that in the process you might figure out what you're doing differently or not yet doing for Android?

                                      In addition, when working with a 3rd party library or files that you want to use in a Qt application for Android the basic requirement is that the library is compiled for any of the Android platforms (usually arm6, arm7 and lately arm8) and that process is usually carried on separately from Qt Creator via the NDK (talking about a C++ library or files). Once you have the (shared) objects created with the NDK you place them in a proper location within the Qt project folder structure and then Qt Creator is finally able to create the Android app and deploy to the device configured in your kit.

                                      So talking about protobuf it couldn't be that different. You need to create with NDK whatever components are required (either a .so or files .cc and .h) and then add such files to your Qt project

                                      Upvote the answer(s) that helped you solve the issue
                                      Use "Topic Tools" button to mark your post as Solved
                                      Add screenshots via postimage.org
                                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                      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