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. How to include libusb libraries for android platform?
Forum Updated to NodeBB v4.3 + New Features

How to include libusb libraries for android platform?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 3 Posters 2.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.
  • R Offline
    R Offline
    Ronak5
    wrote on 5 Mar 2019, 08:39 last edited by Ronak5 3 May 2019, 08:39
    #1

    Hello, I want to include libusb libraries for my android based qt app. I'm able to link it for linux platform.
    But while building for android, I get: "collect2: error: ld returned 1 exit status".

    Which i believe is may be linker isn't able to find the libusb libraries.
    I gave explicit path also in .pro file. (#LIBS += -L/usr/include/libusb-1.0) but didn't help.
    Please help what am i missing here.

    K T 2 Replies Last reply 5 Mar 2019, 10:14
    0
    • R Ronak5
      5 Mar 2019, 08:39

      Hello, I want to include libusb libraries for my android based qt app. I'm able to link it for linux platform.
      But while building for android, I get: "collect2: error: ld returned 1 exit status".

      Which i believe is may be linker isn't able to find the libusb libraries.
      I gave explicit path also in .pro file. (#LIBS += -L/usr/include/libusb-1.0) but didn't help.
      Please help what am i missing here.

      K Offline
      K Offline
      koahnig
      wrote on 5 Mar 2019, 10:14 last edited by
      #2

      @Ronak5

      Do you have a cross-compiled version for this library?

      @Ronak5 said in How to include libusb libraries for android platform?:

      I gave explicit path also in .pro file. (#LIBS += -L/usr/include/libusb-1.0) but didn't help.

      LIBS is the right parameter to specify libraries, but the path you are using seem to be a path for the includes required for compilation. This path seems to be more suitable for INCLUDEPATH.
      Typically the libraries reside to some different path than the includes.

      Vote the answer(s) that helped you to solve your issue(s)

      R 1 Reply Last reply 5 Mar 2019, 10:20
      1
      • K koahnig
        5 Mar 2019, 10:14

        @Ronak5

        Do you have a cross-compiled version for this library?

        @Ronak5 said in How to include libusb libraries for android platform?:

        I gave explicit path also in .pro file. (#LIBS += -L/usr/include/libusb-1.0) but didn't help.

        LIBS is the right parameter to specify libraries, but the path you are using seem to be a path for the includes required for compilation. This path seems to be more suitable for INCLUDEPATH.
        Typically the libraries reside to some different path than the includes.

        R Offline
        R Offline
        Ronak5
        wrote on 5 Mar 2019, 10:20 last edited by Ronak5 3 May 2019, 10:22
        #3

        @koahnig hi

        Do you have a cross-compiled version for this library?
        

        I didn't know this. I thought on inclusion in qt project, android makefile would take care of doing that. So, i've to cross compile libusb separately for android platform then?

        "Typically the libraries reside to some different path than the includes."
        

        yea i've tried other path also as usr/lib etc .
        I tried that as the pkg-config for libusb gave this path : "I/usr/include/libusb-1.0 -lusb-1.0".

        K 1 Reply Last reply 5 Mar 2019, 10:33
        0
        • R Ronak5
          5 Mar 2019, 10:20

          @koahnig hi

          Do you have a cross-compiled version for this library?
          

          I didn't know this. I thought on inclusion in qt project, android makefile would take care of doing that. So, i've to cross compile libusb separately for android platform then?

          "Typically the libraries reside to some different path than the includes."
          

          yea i've tried other path also as usr/lib etc .
          I tried that as the pkg-config for libusb gave this path : "I/usr/include/libusb-1.0 -lusb-1.0".

          K Offline
          K Offline
          koahnig
          wrote on 5 Mar 2019, 10:33 last edited by koahnig 3 Jul 2019, 11:32
          #4

          @Ronak5 said in How to include libusb libraries for android platform?:

          @koahnig hi

          Do you have a cross-compiled version for this library?
          

          I didn't know this. I thought on inclusion in qt project, android makefile would take care of doing that. So, i've to cross compile libusb separately for android platform then?

          use "cross-compile libusb android" in google or different engine.
          We spent a lot of HD space for installing a Qt lib version for Android. IMHO it is a save assumption that you have to do this also for other libraries.

          "Typically the libraries reside to some different path than the includes."

          yea i've tried other path also as usr/lib etc .
          I tried that as the pkg-config for libusb gave this path : "I/usr/include/libusb-1.0 -lusb-1.0".
          

          Possibly this is correct. I just noticed what does not follow common standards. You would need to check if the libs are where you expect. However, this path is typical for your host OS. Out of personal experience I recommend that you should be really careful where you copying/installing stuff. Cross-compiled products have often the same name and a mixture of things are going to invoke nightmares.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          1
          • R Ronak5
            5 Mar 2019, 08:39

            Hello, I want to include libusb libraries for my android based qt app. I'm able to link it for linux platform.
            But while building for android, I get: "collect2: error: ld returned 1 exit status".

            Which i believe is may be linker isn't able to find the libusb libraries.
            I gave explicit path also in .pro file. (#LIBS += -L/usr/include/libusb-1.0) but didn't help.
            Please help what am i missing here.

            T Offline
            T Offline
            Tom_H
            wrote on 7 Mar 2019, 06:47 last edited by
            #5

            @Ronak5 You need to build it for Android. Read the NDK docs on Standalone Toolchains. I had to do this with FreeType. Not fun.

            R 1 Reply Last reply 7 Mar 2019, 09:24
            0
            • T Tom_H
              7 Mar 2019, 06:47

              @Ronak5 You need to build it for Android. Read the NDK docs on Standalone Toolchains. I had to do this with FreeType. Not fun.

              R Offline
              R Offline
              Ronak5
              wrote on 7 Mar 2019, 09:24 last edited by
              #6

              Hi @Tom_H , yes i got a reference here: https://github.com/libusb/libusb/tree/master/android

              Is this what you meant?

              T 1 Reply Last reply 7 Mar 2019, 16:36
              0
              • R Ronak5
                7 Mar 2019, 09:24

                Hi @Tom_H , yes i got a reference here: https://github.com/libusb/libusb/tree/master/android

                Is this what you meant?

                T Offline
                T Offline
                Tom_H
                wrote on 7 Mar 2019, 16:36 last edited by
                #7

                @Ronak5 Yes, you are lucky, libusb includes the required Android build files. So use those instructions for building, but ignore the section under "Installing". You were right in your original post, you just need to include the path in the pro file. Something like this:

                android {
                  contains(ANDROID_ARCHITECTURE, "arm") {
                    LIBS += -L/path/to/armlib/ -lusb
                  }
                  contains(ANDROID_ARCHITECTURE, "x86") {
                    LIBS += -L/path/to/x86lib/ -lusb
                  }
                }
                

                If a project doesn't include specific Android build files, you have to create a Standalone Toolchain as described here:

                https://developer.android.com/ndk/guides/standalone_toolchain

                1 Reply Last reply
                1

                1/7

                5 Mar 2019, 08:39

                • Login

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