Run Raspbian Programs on OpenWrt

分别在两台树莓派(2B)上安装了Raspbian和OpenWrt系统. 某些非静态编译的程序, 会依赖于系统的动态链接库.

如果遇到程序无法运行的情况, 很可能是因为缺少动态链接库. 把Raspbian的/lib/arm-linux-gnueabihf目录搬运到OpenWrt上即可.

On Raspbian

# ssh pi@192.168.1.xxx
$ tar czf arm-linux-gnueabihf.tgz /lib/arm-linux-gnueabihf/
$ scp root@192.168.1.1:/tmp/

On OpenWrt

# ssh root@192.168.1.1
$ tar xzf /tmp/arm-linux-gnueabihf.tgz -C /
$ cd /lib/
$ ln -s arm-linux-gnueabihf/ld-2.19.so ld-linux-armhf.so.3

Test on OpenWrt

rslsync为例

$ wget https://download-cdn.resilio.com/stable/linux-armhf/resilio-sync_armhf.tar.gz
$ tar xzf resilio-sync_armhf.tar.gz -C /usr/bin/ rslsync

$ file /usr/bin/rslsync
/usr/bin/rslsync: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=184eade3540bf47924735944187a818566090b52, stripped

$ ldd /usr/bin/rslsync
    /lib/ld-linux-armhf.so.3 (0x54af7000)
    librt.so.1 => /lib/ld-linux-armhf.so.3 (0x54af7000)
Error loading shared library libcrypt.so.1: No such file or directory (needed by /usr/bin/rslsync)  
    libdl.so.2 => /lib/ld-linux-armhf.so.3 (0x54af7000)
    libm.so.6 => /lib/ld-linux-armhf.so.3 (0x54af7000)
    libpthread.so.0 => /lib/ld-linux-armhf.so.3 (0x54af7000)
    libc.so.6 => /lib/ld-linux-armhf.so.3 (0x54af7000)
Error loading shared library ld-linux-armhf.so.3: No such file or directory (needed by /usr/bin/rslsync)  

Before (Failed)

$ rslsync --help
-ash: rslsync: not found

After (Success)

$ cd /lib/
$ ln -s arm-linux-gnueabihf/ld-2.19.so ld-linux-armhf.so.3
$ rslsync --help