Skip to content
  • Kategorien
  • Aktuell
  • Tags
  • Beliebt
  • Benutzer
  • Gruppen
  • Suche
  • Get Qt Extensions
  • Ungelöst
Einklappen
Markenlogo
  1. Übersicht
  2. Qt Development
  3. Mobile and Embedded
  4. How to use libusb for android at Qt Creatror.
Forum Updated to NodeBB v4.3 + New Features

How to use libusb for android at Qt Creatror.

Geplant Angeheftet Gesperrt Verschoben Mobile and Embedded
23 Beiträge 3 Kommentatoren 12.0k Aufrufe 1 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • X Offline
    X Offline
    xmaze
    schrieb am zuletzt editiert von
    #1

    Hallo!!

    I try to use libusb1.0 with android and qt creator.
    @Installing:

    If you wish to use libusb from native code in own Android application
    then you should add the following line to your Android.mk file:

    include $(PATH_TO_LIBUSB_SRC)/android/jni/libusb.mk

    You will then need to add the following lines to the build
    configuration for each native binary which uses libusb:

    LOCAL_C_INCLUDES += $(LIBUSB_ROOT_ABS)
    LOCAL_SHARED_LIBRARIES += libusb1.0

    The Android build system will then correctly include libusb in the
    application package (APK) file, provided ndk-build is invoked before
    the package is built.@

    This is the readme from libusb but i cannot understand what is Android.mk because if i create a project at Qt i dont have android.mk file. And where is "build configurations" at Qt creator ?

    Can someone help ?

    1 Antwort Letzte Antwort
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      schrieb am zuletzt editiert von
      #2

      Hi,

      Android.mk is used in the Android NDK to build your application which is not the same thing as using Qt to build your project.

      You have to modify your pro file to link to libusb1.0.

      Something like:

      @
      LIBS += -L/path/to/android_NDK/folder/to/libusb.1.0_library
      -lusb1.0
      INCLUDEPATH += /path/to/android_NDK/folder/to/libusb.1.0_include(s)
      @

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Antwort Letzte Antwort
      0
      • X Offline
        X Offline
        xmaze
        schrieb am zuletzt editiert von
        #3

        i think something its different,

        @ The libusb library, examples and tests can then be found in:
        "android/libs/$ARCH"

        Where $ARCH is one of:
        armeabi
        armeabi-v7a
        x86
        @

        in this path you have wrote i cannot find libraries, only in /home/unix/Downloads/libusb-master/android/libs there is libs. Are you mean that ?

        1 Antwort Letzte Antwort
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          schrieb am zuletzt editiert von
          #4

          Indeed, adapt the paths to your system

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Antwort Letzte Antwort
          0
          • X Offline
            X Offline
            xmaze
            schrieb am zuletzt editiert von
            #5

            i think that my previus post sounds stupid, i mean that in NDK folder i dont have the usb library, but i think in the libusb-master folder exist the library , i build it with the NDK builder. I will try to linking this folder and i will see if it's working.

            1 Antwort Letzte Antwort
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              schrieb am zuletzt editiert von
              #6

              No it doesn't, the library doesn't necessarily need to be in the NDK tree.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Antwort Letzte Antwort
              0
              • X Offline
                X Offline
                xmaze
                schrieb am zuletzt editiert von
                #7

                @ LIBS += -L/home/unix/Downloads/libusb-master/android/libs/armeab
                -l libusb1.0.so
                INCLUDEPATH += /home/unix/Downloads/libusb-master/android/libs/armeabi @

                i have made this changes but i have also the following error

                @/home/unix/MyCODE/QT_Creator/src/librtlsdr.c:30: error: libusb.h: No such file or directory
                #include <libusb.h>@

                any ideas ?

                1 Antwort Letzte Antwort
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  schrieb am zuletzt editiert von
                  #8

                  Where is libusb.h located ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Antwort Letzte Antwort
                  0
                  • X Offline
                    X Offline
                    xmaze
                    schrieb am zuletzt editiert von
                    #9

                    at

                    /home/unix/Downloads/libusb-master/lib-usb

                    but i am confused, i built the libraries for Android, need i the sourche or the compiled libs ?

                    1 Antwort Letzte Antwort
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      schrieb am zuletzt editiert von
                      #10

                      If you have it already built, just correct the INCLUDEPATH statement

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Antwort Letzte Antwort
                      0
                      • X Offline
                        X Offline
                        xmaze
                        schrieb am zuletzt editiert von
                        #11

                        @LIBS += -L/home/unix/Downloads/libusb-master/android/libs/armeabi
                        -lusb1.0
                        INCLUDEPATH += /home/unix/Downloads/libusb-master/android/libs/armeabi@

                        i have now this path to libraries, this is the builded one libraries with NDK. But its interesting, where can i learn how to use other libraries ? Now the libusb is embedded in APK file ?
                        Can you explain if the Qt creator can build from source the libs for Android or how can i use other C libraries in Android Apps ?

                        1 Antwort Letzte Antwort
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          schrieb am zuletzt editiert von
                          #12

                          Qt Creator is an IDE, it can't build "any and every project". Depending on the library you'd like to use with android, you'll have to build them either using the library provided scripts or adapt it yourself.

                          As for integrating other libraries, it's the same process you did for libusb

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Antwort Letzte Antwort
                          0
                          • X Offline
                            X Offline
                            xmaze
                            schrieb am zuletzt editiert von
                            #13

                            That means that i have two choices, i can use the source code of a library direct into the project or to use a link to builded shared object ?

                            am i right ?

                            1 Antwort Letzte Antwort
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              schrieb am zuletzt editiert von
                              #14

                              You can't always just include the source code of a library in your project. Some of them requires configuration to e.g. enable functionalities based on your system's installed libraries etc.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Antwort Letzte Antwort
                              0
                              • X Offline
                                X Offline
                                xmaze
                                schrieb am zuletzt editiert von
                                #15

                                i mean only for android because it's an external device and not my system. i think need to port the source code for Android or not ?

                                1 Antwort Letzte Antwort
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  schrieb am zuletzt editiert von
                                  #16

                                  That depends on the library and what it does

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Antwort Letzte Antwort
                                  0
                                  • S Offline
                                    S Offline
                                    sxubach
                                    schrieb am zuletzt editiert von
                                    #17

                                    Hello, I was trying to do exactly the same but I am having some problem following this indications. Right now I have

                                    LIBS += -L/home/toad/libusb-1.0.19/android/libs/armeabi-v7a -libusb1.0.so
                                    INCLUDEPATH += /home/toad/libusb-1.0.19/android/libs/armeabi-v7a
                                    

                                    and in the .cpp file I want to use the libarry I have

                                    #include <libusb.h>

                                    also tried

                                    #include "/home/esaote/libusb-1.0.19/android/libs/armeabi-v7a/libusb1.0.so"

                                    but it keeps on giving the error: undefined reference to 'libusb_whatever'

                                    What am I doing wrong?

                                    1 Antwort Letzte Antwort
                                    0
                                    • X Offline
                                      X Offline
                                      xmaze
                                      schrieb am zuletzt editiert von
                                      #18

                                      LIBS += -L/home/unix/Downloads/libusb-master/android/libs/armeabi-v7a\
                                      -lusb1.0

                                      this working for me , very important this slash,
                                      -L/home/unix/Downloads/libusb-master/android/libs/armeabi-v7a\ <==== ()

                                      1 Antwort Letzte Antwort
                                      0
                                      • S Offline
                                        S Offline
                                        sxubach
                                        schrieb am zuletzt editiert von
                                        #19

                                        without any include on the .cpp file?

                                        1 Antwort Letzte Antwort
                                        0
                                        • X Offline
                                          X Offline
                                          xmaze
                                          schrieb am zuletzt editiert von
                                          #20

                                          only in .h file #include <libusb.h> and of course your INCLUDEPATH += /home/toad/
                                          but not to lib, you need to point the source files from libusb , like this
                                          INCLUDEPATH += /home/unix/Downloads/libusb-master/libusb

                                          1 Antwort Letzte Antwort
                                          0

                                          • Anmelden

                                          • Anmelden oder registrieren, um zu suchen
                                          • Erster Beitrag
                                            Letzter Beitrag
                                          0
                                          • Kategorien
                                          • Aktuell
                                          • Tags
                                          • Beliebt
                                          • Benutzer
                                          • Gruppen
                                          • Suche
                                          • Get Qt Extensions
                                          • Ungelöst