title: Cannot open shared library (so) on Raspberry Pi
body: <p>I am trying to run a ARM shared object binary compiled for Android (found within an .apk) on Raspberry PI ARM machine.</p>
  <p>Unfortunately the binary is closed source and I cannot recompile it for the os which runs on  raspberry pi (raspian, debian derivation)</p>
  <p>Quick question: Is it possible to run such a .so compiled for android on raspberry pi? I uploaded the binary here: <a href="http://www.speedyshare.com/MSXq9/libfoo.so" rel="nofollow noreferrer">http://www.speedyshare.com/MSXq9/libfoo.so</a> (Sorry for inconvenient download).</p>
  <p>I found this similar question here <a href="https://stackoverflow.com/questions/11383813/running-arm-binaries-for-android-on-linux-arm">Running ARM binaries for Android on Linux ARM</a> and it suggests that binaries won't run on other unix distros (I use a derivation of debian, raspian on my raspberry) since android's c library is Bionic.</p>
  <p>Can one install bionic on debian? How could I manage to run this library?</p>
  <p><strong>All the following output was generated on the rasbperry machine were I want to run/load libfoo.so.</strong></p>
  <p>When I try to load the .so file in python (before, I set LD_PRELOAD accordingly)</p>
  <pre><code>import ctypes 
  import os
  
  path = os.path.dirname(os.path.realpath(__file__))
  print ctypes.cdll.LoadLibrary('libfoo.so')
  </code></pre>
  <p>I get an OSError: <em>libfoo.so: cannot open shared object file: No such file or directory</em>.</p>
  <p>But after looking on the strace output, it seems like the loader cannot load libfoo.so and thus fails with the slightly misleading error message <em>No such file or directory</em> (After all the .so is found and the loader tries to load it, but fails while doing so).</p>
  <p>When issuing <strong>readelf -h libfoo.so</strong> I get</p>
  <pre><code>root@raspberrypi:/home/pi# readelf -h libfoo.so 
  ELF Header:
    Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
    Class:                             ELF32
    Data:                              2's complement, little endian
    Version:                           1 (current)
    OS/ABI:                            UNIX - System V
    ABI Version:                       0
    Type:                              DYN (Shared object file)
    Machine:                           ARM
    Version:                           0x1
    Entry point address:               0x10b60
    Start of program headers:          52 (bytes into file)
    Start of section headers:          341440 (bytes into file)
    Flags:                             0x5000002, has entry point, Version5 EABI
    Size of this header:               52 (bytes)
    Size of program headers:           32 (bytes)
    Number of program headers:         5
    Size of section headers:           40 (bytes)
    Number of section headers:         21
    Section header string table index: 20
  </code></pre>
  <p>Furthermore theh <strong>attribute section aeabi</strong> for libfoo.so (obtained with <strong>readelf --all</strong>)</p>
  <pre><code>No version information found in this file.
  Attribute Section: aeabi
  File Attributes
    Tag_CPU_name: &quot;5TE&quot;
    Tag_CPU_arch: v5TE
    Tag_ARM_ISA_use: Yes
    Tag_THUMB_ISA_use: Thumb-1
    Tag_ABI_PCS_wchar_t: 4
    Tag_ABI_FP_denormal: Needed
    Tag_ABI_FP_exceptions: Needed
    Tag_ABI_FP_number_model: IEEE 754
    Tag_ABI_align_needed: 8-byte
    Tag_ABI_align_preserved: 8-byte, except leaf SP
    Tag_ABI_enum_size: int
  </code></pre>
  <p>And in comparison the same output as above for a locally compiled .so on the raspberry platform where I am trying to run libfoo.so:</p>
  <pre><code>  Attribute Section: aeabi
  File Attributes
    Tag_CPU_name: &quot;6&quot;
    Tag_CPU_arch: v6
    Tag_ARM_ISA_use: Yes
    Tag_THUMB_ISA_use: Thumb-1
    Tag_FP_arch: VFPv2
    Tag_ABI_PCS_wchar_t: 4
    Tag_ABI_FP_denormal: Needed
    Tag_ABI_FP_exceptions: Needed
    Tag_ABI_FP_number_model: IEEE 754
    Tag_ABI_align_needed: 8-byte
    Tag_ABI_align_preserved: 8-byte, except leaf SP
    Tag_ABI_enum_size: int
    Tag_ABI_HardFP_use: SP and DP
    Tag_ABI_VFP_args: VFP registers
    Tag_ABI_optimization_goals: Aggressive Speed
    Tag_DIV_use: Not allowed
  </code></pre>
  <p>There are some differences in the CPU the shared libraries were compiled for, but I assume it sholdn't matter since ARM architectures are downwards compatible.</p>
  <p>Here the strace output <strong>for trying to load libfoo.so</strong>:</p>
  <pre><code>  root@raspberrypi:/home/pi# strace ./test -s libfoo.so
  execve(&quot;./test&quot;, [&quot;./test&quot;, &quot;-s&quot;, &quot;libfoo.so&quot;], [/* 19 vars */]) = 0
  brk(0)                                  = 0x36f000
  uname({sys=&quot;Linux&quot;, node=&quot;raspberrypi&quot;, ...}) = 0
  access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)
  mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f6a000
  access(&quot;/etc/ld.so.preload&quot;, R_OK)      = 0
  open(&quot;/etc/ld.so.preload&quot;, O_RDONLY)    = 3
  fstat64(3, {st_mode=S_IFREG|0644, st_size=44, ...}) = 0
  mmap2(NULL, 44, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0xb6f69000
  close(3)                                = 0
  open(&quot;/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so&quot;, O_RDONLY) = 3
  read(3, &quot;\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\4\0\0004\0\0\0&quot;..., 512) = 512
  lseek(3, 7276, SEEK_SET)                = 7276
  read(3, &quot;\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&quot;..., 1080) = 1080
  lseek(3, 7001, SEEK_SET)                = 7001
  read(3, &quot;A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25&quot;..., 47) = 47
  fstat64(3, {st_mode=S_IFREG|0755, st_size=10170, ...}) = 0
  mmap2(NULL, 39740, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f3e000
  mprotect(0xb6f40000, 28672, PROT_NONE)  = 0
  mmap2(0xb6f47000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6f47000
  close(3)                                = 0
  munmap(0xb6f69000, 44)                  = 0
  open(&quot;/usr/lib/tls/v6l/vfp/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/tls/v6l/vfp&quot;, 0xbea66f20) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/tls/v6l/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/tls/v6l&quot;, 0xbea66f20)  = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/tls/vfp/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/tls/vfp&quot;, 0xbea66f20)  = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/tls/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/tls&quot;, 0xbea66f20)      = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/v6l/vfp/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/v6l/vfp&quot;, 0xbea66f20)  = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/v6l/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/v6l&quot;, 0xbea66f20)      = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/vfp/libdl.so.2&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/vfp&quot;, 0xbea66f20)      = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/libdl.so.2&quot;, O_RDONLY)   = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib&quot;, {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
  open(&quot;/etc/ld.so.cache&quot;, O_RDONLY)      = 3
  fstat64(3, {st_mode=S_IFREG|0644, st_size=43090, ...}) = 0
  mmap2(NULL, 43090, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f33000
  close(3)                                = 0
  access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/libdl.so.2&quot;, O_RDONLY) = 3
  read(3, &quot;\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\t\0\0004\0\0\0&quot;..., 512) = 512
  lseek(3, 8652, SEEK_SET)                = 8652
  read(3, &quot;\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&quot;..., 1160) = 1160
  lseek(3, 8320, SEEK_SET)                = 8320
  read(3, &quot;A0\0\0\0aeabi\0\1&amp;\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25&quot;..., 49) = 49
  fstat64(3, {st_mode=S_IFREG|0644, st_size=9812, ...}) = 0
  mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f28000
  mprotect(0xb6f2a000, 28672, PROT_NONE)  = 0
  mmap2(0xb6f31000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6f31000
  close(3)                                = 0
  open(&quot;/usr/lib/libc.so.6&quot;, O_RDONLY)    = -1 ENOENT (No such file or directory)
  access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/libc.so.6&quot;, O_RDONLY) = 3
  read(3, &quot;\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\214y\1\0004\0\0\0&quot;..., 512) = 512
  lseek(3, 1198880, SEEK_SET)             = 1198880
  read(3, &quot;\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&quot;..., 1360) = 1360
  lseek(3, 1198444, SEEK_SET)             = 1198444
  read(3, &quot;A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25&quot;..., 47) = 47
  fstat64(3, {st_mode=S_IFREG|0755, st_size=1200240, ...}) = 0
  mmap2(NULL, 1242408, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6df8000
  mprotect(0xb6f1b000, 28672, PROT_NONE)  = 0
  mmap2(0xb6f22000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x122) = 0xb6f22000
  mmap2(0xb6f25000, 9512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f25000
  close(3)                                = 0
  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f69000
  set_tls(0xb6f694c0, 0xb6f69b98, 0xb6f6e048, 0xb6f694c0, 0xb6f6e048) = 0
  mprotect(0xb6f22000, 8192, PROT_READ)   = 0
  mprotect(0xb6f31000, 4096, PROT_READ)   = 0
  mprotect(0xb6f6d000, 4096, PROT_READ)   = 0
  munmap(0xb6f33000, 43090)               = 0
  open(&quot;/usr/lib/libfoo.so&quot;, O_RDONLY) = 3
  read(3, &quot;\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`\v\1\0004\0\0\0&quot;..., 512) = 512
  lseek(3, 341440, SEEK_SET)              = 341440
  read(3, &quot;\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&quot;..., 840) = 840
  lseek(3, 341224, SEEK_SET)              = 341224
  read(3, &quot;A(\0\0\0aeabi\0\1\36\0\0\0\0055TE\0\6\4\10\1\t\1\22\4\24\1\25&quot;..., 41) = 41
  close(3)                                = 0
  open(&quot;/etc/ld.so.cache&quot;, O_RDONLY)      = 3
  fstat64(3, {st_mode=S_IFREG|0644, st_size=43090, ...}) = 0
  mmap2(NULL, 43090, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f33000
  close(3)                                = 0
  access(&quot;/etc/ld.so.nohwcap&quot;, F_OK)      = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/tls/v6l/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/tls/v6l/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/tls/v6l/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/tls/v6l&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/tls/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/tls/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/tls/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/tls&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/v6l/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/v6l/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/v6l/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/v6l&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/lib/arm-linux-gnueabihf/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/arm-linux-gnueabihf&quot;, {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
  open(&quot;/usr/lib/arm-linux-gnueabihf/tls/v6l/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/tls/v6l/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/tls/v6l/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/tls/v6l&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/tls/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/tls/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/tls/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/tls&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/v6l/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/v6l/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/v6l/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/v6l&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf/vfp&quot;, 0xbea66f40) = -1 ENOENT (No such file or directory)
  open(&quot;/usr/lib/arm-linux-gnueabihf/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/usr/lib/arm-linux-gnueabihf&quot;, {st_mode=S_IFDIR|0755, st_size=28672, ...}) = 0
  open(&quot;/lib/tls/v6l/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/tls/v6l/vfp&quot;, 0xbea66f40)  = -1 ENOENT (No such file or directory)
  open(&quot;/lib/tls/v6l/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/tls/v6l&quot;, 0xbea66f40)      = -1 ENOENT (No such file or directory)
  open(&quot;/lib/tls/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/tls/vfp&quot;, 0xbea66f40)      = -1 ENOENT (No such file or directory)
  open(&quot;/lib/tls/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/tls&quot;, 0xbea66f40)          = -1 ENOENT (No such file or directory)
  open(&quot;/lib/v6l/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/v6l/vfp&quot;, 0xbea66f40)      = -1 ENOENT (No such file or directory)
  open(&quot;/lib/v6l/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/v6l&quot;, 0xbea66f40)          = -1 ENOENT (No such file or directory)
  open(&quot;/lib/vfp/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib/vfp&quot;, 0xbea66f40)          = -1 ENOENT (No such file or directory)
  open(&quot;/lib/libfoo.so&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
  stat64(&quot;/lib&quot;, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
  open(&quot;/usr/lib/libfoo.so&quot;, O_RDONLY) = 3
  read(3, &quot;\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`\v\1\0004\0\0\0&quot;..., 512) = 512
  lseek(3, 341440, SEEK_SET)              = 341440
  read(3, &quot;\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&quot;..., 840) = 840
  lseek(3, 341224, SEEK_SET)              = 341224
  read(3, &quot;A(\0\0\0aeabi\0\1\36\0\0\0\0055TE\0\6\4\10\1\t\1\22\4\24\1\25&quot;..., 41) = 41
  close(3)                                = 0
  brk(0)                                  = 0x36f000
  brk(0x390000)                           = 0x390000
  munmap(0xb6f33000, 43090)               = 0
  fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f68000
  write(1, &quot;Service libfoo.so Not Fo&quot;..., 115Service libfoo.so Not Found:  libfoo.so: cannot open shared object file: No such file or directory
  ) = 115
  write(1, &quot;Problem calling generic_function&quot;..., 91Problem calling generic_function_entry(): ./test: undefined symbol: generic_function_entry
  ) = 91
  --- SIGSEGV (Segmentation fault) @ 0 (0) ---
  +++ killed by SIGSEGV +++
  Segmentation fault
  </code></pre>