mac电脑上编译能在ios上用的 ffmpeg 静态库 (成功经验)有疑问可以留言

首先,相信你已经有了ffmpeg,废话不多说,你仍然需要另外的一个文件,gas-preprocessor.pl 这个文件相信你也会想尽办法找到,所有的一切具备之后,下面让我们开始编译。

1,打开终端,cd到ffmpeg所在目录。例如:cd /users/apple/documents/ffmpeg,回车,

这里我编译了三份,分别是:i386,armv7,armv7s 框架下的,如果需要armv6框架下的可以自己尝试着编译,毕竟现在很少人用了。

好了! i386:


./configure --cc=/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc --as='./gas-preprocessor.pl /Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc' --extra-ldflags=-L/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/lib/system --sysroot=/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-armv5te --disable-asm --enable-cross-compile --enable-decoder=h264 --enable-pic --target-os=darwin --arch=i386 --cpu=i386 --extra-cflags='-arch i386' --extra-ldflags='-arch i386'

输入上面这句回车,成功后会出现类似:

License: LGPL version 2.1 or later
Creating config.mak and config.h...
libavutil/avconfig.h is unchanged


WARNING: pkg-config not found, library detection may fail.
localhost:ffmpeg apple$


这样说明已经配置完了,然后 make回车。最后出现类似:

STRIP ffprobe
localhost:ffmpeg apple$

然后,make install 好了 成功了,现在你就可以将编译好的静态库,拷贝到别的地方存起来了 。类似下面这种:

cp libavcodec/libavcodec.a ./lib/i386/libavcodec.a

这样你就将 libavcodec.a库拷贝到了 i386文件夹下,当你将所需要的库全部拷贝出来后,你就可以清除掉编译好的库在当前目录下的。


执行 make clean 命令就可以了。 接下来你可以照此方法编译armv7,跟armv7s框架下的。

具体配置已经写好了:

//armv7下

./configure --cc=/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='./gas-preprocessor.pl /Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --sysroot=/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-armv5te --disable-asm --enable-cross-compile --enable-decoder=h264 --enable-pic --target-os=darwin --arch=arm --cpu=cortex-a8 --extra-cflags='-arch armv7'


//armv7s下

./configure --cc=/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='./gas-preprocessor.pl /Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --extra-ldflags='-arch armv7s -isysroot /Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --sysroot=/Applications/Xcode4.5.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-armv5te --disable-asm --enable-cross-compile --enable-decoder=h264 --enable-pic --target-os=darwin --arch=arm --cpu=cortex-a8 --extra-cflags='-arch armv7s'


如果 三个框架下的库 你都编译完了,那说明你已经相当的成功了,只差一步,那就是将三个版本的库合成一个,那么在任何框架下就都能用了。

这样

// merge



lipo -create lib/i386/libavcodec.a lib/arm7/libavcodec.a lib/arm7s/libavcodec.a -output lib/libavcodec.a
lipo -create lib/i386/libavformat.a lib/arm7/libavformat.a lib/arm7s/libavformat.a -output lib/libavformat.a
lipo -create lib/i386/libavdevice.a lib/arm7/libavdevice.a lib/arm7s/libavdevice.a -output lib/libavdevice.a
lipo -create lib/i386/libavutil.a lib/arm7/libavutil.a lib/arm7s/libavutil.a -output lib/libavutil.a
lipo -create lib/i386/libswscale.a lib/arm7/libswscale.a lib/arm7s/libswscale.a -output lib/libswscale.a


这里的所有的路径都是我电脑上编译时的路径,具体到每台电脑上,路径不同的自己看看改了就行了 再就是我编译的时候xcode的版本是4.5.2的 所以我写的是Xcode4.5.2.app很多的地方用到 存在于路径中,你可以视具体情况而定。


再就是 有一点 步骤中的make install我一直不明白有啥用处。从网上查,很多地方都用到了 不过貌似跳过这一步也不会有任何问题,没事的时候可以拿来编译一下,也可以增加些自信。最后祝你成功。!!!


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值