交叉编译工具下载地址 :
https://launchpad.net/linaro-toolchain-binaries/+download
其中我下载的是 :
gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux.tar.xz (md5, sig) arm- Linux-gnueabihf crosscompiler for Linux
在CentOS 64 位环境下交叉编译 ffmpeg
./configure --sysroot=/home/arm_linux/arm-linux-gnueabihf/libc --enable-cross-compile --arch=arm --target-os=linux --cross-prefix=/home/arm_linux/bin/arm-linux-gnueabihf-
提示如下错误:
arm-linux-gnueabihf/arm-linux-gnueabihf/bin/gcc: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
C compiler test failed.
上面这个错误执行
[root@localhost ffmpeg-1.1.3]# yum install ld-linux.so.2
后解决。
然后继续configure , 又碰到下面的错误 :
[root@localhost ffmpeg-1.1.3]# /usr/routing/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc test.c
/usr/routing/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
这个错误后来换了 32 位的系统后解决。
编译完成后在目标机器上执行, 出错 :
[plain] view plain copy
- root@cubieboard2:/home/linaro# ldd ffmpeg
- ./ffmpeg: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by ./ffmpeg)
- libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6ee2000)
- libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6ec6000)
- libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6de2000)
- /lib/ld-linux-armhf.so.3 (0xb6f58000)
这个问题是因为交叉编译工具的 glibc库的版本和目标机器上的glibc库的版本不一致造成的,
解决办法就是静态链接 glibc库,执行下面的命令重新生成Mkaefile文件。
./configure --sysroot=/home/arm_linux/arm-linux-gnueabihf/libc --enable-cross-compile --arch=arm --target-os=linux --cross-prefix=/home/arm_linux/bin/arm-linux-gnueabihf- --extra-libs=/home/arm_linux/arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libc.a
make
下来在目标机器上查看就正常了 :
[plain] view plain copy
- root@cubieboard2:/home/linaro# ldd ffmpeg
- libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6ec6000)
- libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6ea3000)
- libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6e88000)
- libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6da4000)
- /lib/ld-linux-armhf.so.3 (0xb6f3c000)
不过运行的时候出问题了 :
root@cubieboard2:/home/linaro# ./ffmpeg
unexpected reloc type in static binaryAborted
看来静态链接libc库不是个办法。。。
还有一招, 就是直接从目标机器里把 libc.so.6 和 librt.so.1 这两个库 复制到 交叉编译机器, 覆盖源文件, 然后再重新编译即可。
执行 ffmpeg , 现在可以执行了, 不过有丢包, 有编解码失败的情况 , PC上没问题:
[plain] view plain copy
- [h264 @ 0x15b80a0] RTP: missed 28 packets
- [h264 @ 0x15b80a0] RTP: missed 5 packets
- [h264 @ 0x15b80a0] error while decoding MB 75 37, bytestream (-10)
- [h264 @ 0x15b80a0] concealing 614 DC, 614 AC, 614 MV errors in P frame
- RTP: missed 3 packets=17.1 size= 1062kB time=00:00:41.48 bitrate= 209.7kbits/s dup=0 drop=5
- [h264 @ 0x15b80a0] RTP: missed 6 packets
- [h264 @ 0x15b80a0] RTP: missed 3 packets
- Last message repeated 1 times
- [h264 @ 0x15b80a0] RTP: missed 6 packets
- [h264 @ 0x15b80a0] RTP: missed 3 packets
- [h264 @ 0x15b80a0] RTP: missed 6 packets
- [h264 @ 0x15b80a0] RTP: missed 3 packets
- [h264 @ 0x15b80a0] RTP: missed 6 packets
- RTP: missed 28 packets17.1 size= 1062kB time=00:00:41.48 bitrate= 209.7kbits/s dup=0 drop=5
- [h264 @ 0x15b80a0] error while decoding MB 61 34, bytestream (-5)
- [h264 @ 0x15b80a0] concealing 868 DC, 868 AC, 868 MV errors in P frame
- [h264 @ 0x15b80a0] RTP: missed 25 packets
- [h264 @ 0x15b80a0] error while decoding MB 40 34, bytestream (-7)
- [h264 @ 0x15b80a0] concealing 889 DC, 889 AC, 889 MV errors in P frame
- [h264 @ 0x15b80a0] RTP: missed 49 packets
- [h264 @ 0x15b80a0] error while decoding MB 9 20, bytestream (-20)