2012年12月24日 星期一

編譯 IOS 用的 libav + libspeex + libogg 時候遇到的問題解析

Our project needs libav(ffmpeg) + speex, so it is needed to compile three libraries
libogg, speex 1.2rc1 and libav.
The resource on the internet helped a lot, but there still several things needed to work out :
1.  Libraries along can work, but can't generate a "multi-architecture" library with lipo. The error is lack of "architecture" information in armv7 libraries.
Root cause :
The debug information hides the compiled architecture information
Solution :
Add "-O1" or "-O3" in CFLAGS, avoid to use "-O4"

2. can not find assembler , install gas_preprocessor.pl
Root cause :
The environment variable CFLAGS is not applied to "gas_preprocessor.pl"
Solution :
need to put the flags into configure option --extra-cflags "$CFLAGS"

3. After applying "-O3 -pipe -dwarf-2 -no-cpp-precomp -fPIC -marm" option in CFLAGS, compiling h264_cabac, it shows Ran out of registers during register allocation.
Root cause :
Some codes in libav are optimized with assemble code with specified with some architectures. But the instruction implementation is not correct with this version of XCode compiler.
Solution :
1. Use gas_preprocessor.pl
2. If you don't have it, use the command
perl -pi -e "s/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/" config.h

4. In XCode, it errors with "R_ABS reloc but no absolute symbol at target" ... What is this ?
Root cause :
The face reason is symbol table fail. But ... we are using compiler and symbol tables are generated automatically and magically. The reason is the arm thumb2 instruction set was not implemented in this version of compiler.
Solution :
We need to add "--disable-thumb" in configure options

There are many small problems and great solutions, but combining of all together will .... fail. The solutions I verified several times with performance and usability consideration.

沒有留言: