0

I need to load the library ld-uClibc-0.9.30.1.so for my Android Eclipse project. I try to load it with Sytem.load("/root/workspace/libs/ld-uClibc-0.9.30.1.so") from my host computer but I get the error:

Cannot load library /root/workspace/libs/ld-uClibc-0.9.30.1.so. Library not found.

What is the matter? Why does it not work with System.load?

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
Eddy Gordo
  • 61
  • 1
  • 7
  • That does not sound like an Android compatible library – Chris Stratton Jul 09 '12 at 12:18
  • Ok,can you tell me how I can know whether a library is Android compatible or not? – Eddy Gordo Jul 09 '12 at 12:30
  • By the tool chain that generated it, or the errors in loading it. In this case though, the name if the library suggests it. uClibc is the C library for a small system, but Android has its own C library called Bionic which is already loaded when your app starts. You should recompile the code that needs this with the android ndk so it gets linked against Bionic instead. – Chris Stratton Jul 09 '12 at 12:41
  • Ok the ld-uClibc-0.9.30.1.so is a dependecy of the libusb.so. I did not compile the libusb.so with the ndk. I only took it from the /usr/lib folder of the Android device. So do you think I have to compile the libusb.so with the ndk to make this work? Did you mean that by "..the code that needs this.." ? – Eddy Gordo Jul 09 '12 at 12:47
  • This seems like an unusual android device if it really came with a /usr/lib/libusb.so. If and only if these libraries shipped on the device, what error does System.load("/usr/lib/ld-uClibc-0.9.30.1.so") or whatever the file path is, generate in logcat? – Chris Stratton Jul 09 '12 at 13:56
  • It generates the error "Could not load library 'ld-uC....'" or Could not find library. I can't tell you exactly because the device is in my workplace and I quit working for today. I will continue with this issue tommorow and then I can give some more details. Thanks for your help. – Eddy Gordo Jul 09 '12 at 14:09

3 Answers3

0

Add the library into the libs folder which is inside the project folder, then call

System.loadLibrary("ld-uClibc-0.9.30.1");
Nermeen
  • 15,883
  • 5
  • 59
  • 72
  • I does not work like that. System.loadLibrary("ld-uClibc-0.9.30.1"); does not work either. Actually with System.load() one has to give the library with its full path. But nothing has worked yet. – Eddy Gordo Jul 09 '12 at 10:29
  • It does not work with System.loadLibrary either. What could be the matter? – Eddy Gordo Jul 09 '12 at 11:39
0

Just realized what the real problem is. I had been thinking you were trying to load the uClibc C library. But actually, that is not the case. You are trying to load the uClibc dynamic linker, in order to resolve dependencies in a version of libusb linked against uClibc rather than bionic.

This is just not going to work (at least not without obscene hackery)

You need to rebuild everything linked against bionic, using the ndk toolchain, possible via its generate stand alone toolchain function.

But, trying to get libusb working on android without root or the ability to modify the device file permissions is likely an exercise in futility.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • OK, how do I rebuild everything linked against bionic? Sorry for this question but as I already mentioned I am an absolute Android beginner. And is it really almost impossible to get libusb to work on an unrooted Android device? What are the main problems? I have not found much about it on the internet. Because if it is something impossible, I don't want to waste too much time for it. – Eddy Gordo Jul 09 '12 at 19:51
  • The question would be if you can get access to the raw device files. Most everywhere else in android you cannot, and have to talk through system-level userspace proxies. – Chris Stratton Jul 09 '12 at 23:34
0

I compiled the libusb.so with the NDK and now at least it can be loaded within the Android project. I think this topic can be cosidered as answered. I will post another question concerning the use of libusb on Android. I would appreciate it if you all still give me some good hints because it has helped me alot until now.

Eddy Gordo
  • 61
  • 1
  • 7