How to include libusb libraries for android platform?
-
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. -
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. -
@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". -
@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.
-
@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