I\'ve two files:
lib.c
#include
void hi() {
printf("Hi i\'m a library function in lib.so\\n");
}
and main
The "not found" message refers not to the shared object but to the dynamic linker. Linux uses /lib/ld-linux.so.2
(or /lib64/ld-linux-x86-64.so.2
for x64) while Android uses /bin/linker
. You can check which dynamic loader your program uses with readelf -l
, e.g.:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x08048034 0x08048034 0x00100 0x00100 R E 0x4
INTERP 0x000134 0x08048134 0x08048134 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
You can specify a linker to use with ld's --dynamic-linker
switch, but there are likely to be other differences. For example, Android uses a stripped-down libc implementation called bionic, and it may be missing functionality that your program relies on, or have different behavior.
You should use NDK or another Android-targeted toolchain when compiling programs for Android. Even though it's based on Linux kernel, the differences are large enough that Linux-targeted toolchains are not sufficient.