13

WARNING:

I was just informed by another user that there are some legal issues revolving around using FFMPEG for iOS, leaving the link here http://multinc.com/2009/08/24/compatibility-between-the-iphone-app-store-and-the-lgpl/

I cleaned up my question a little bit, when I wrote it the first time I was flustered. Now I can be more clear after taking a small break.

Edit: learned that you have to build for ARMv7, ARMv7s and iOS6.0

I'm trying to use the FFMPEG library in an XCode 4.5.1 project. And I'm trying to build it for ARMv7. What I'm looking for is the exact process, and some explanation. I understand that this is not a well documented problem. But I know that other pople have had the same problem as me.

What I have been able to do.

I have been able to build the library for testing.

1) I have been able to clone ffmpeg. For beginners this will get you started by creating a directory with the ffmpeg source. (Kudos to the guys who wrote it)

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

2) I have been able to write a config file that doesn't have any errors. We will go back to this part later. This is the command I attach to ./configure

./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2

--as='gas-preprocessor/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2'

--sysroot=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk

--cpu=cortex-a8 --extra-ldflags='-arch=armv7 -isysroot /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --enable-pic --disable-bzlib --disable-gpl --disable-shared --enable-static --disable-mmx --disable-debug --disable-neon --extra-cflags='-pipe -Os -gdwarf-2 -isysroot /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -m${thumb_opt:-no-thumb} -mthumb-interwork'

These are some things to note.

  • I had to download ( https://github.com/yuvi/gas-preprocessor ) copy the file gas-preprocessor.pl at /usr/local/bin. Set permissions to read write (777)
  • Make sure I'm using the right GCC compiler: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2
  • Make sure I'm using the right SDK: /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
  • --extra-cflags="-arch armv7" causes: error: unrecognized command line option “-arch”

Here in lies the problem.

I can include the library like so

libavcodec/avcodec.h

But when I started to write the encoder. I received this warning, and countless errors.

ignoring file /Users/Jimmy/Development/source.ffmpeg/Library/libavutil.a, file was built for archive which is not the architecture being linked (armv7s): /Users/Jimmy/Development/source.ffmpeg/Library/libavutil.a

That means that I didn't build the right binary.

What I'm looking for is someone whose done it before, to walk all of us through the process of building FFMPEG for iOS6.0 and ARMv7 and the majority of things to look out for. Thanks a ton.

Jim
  • 1,274
  • 1
  • 10
  • 15
  • So, what does `config.log` say? Can you identify the failing program? Post `config.log` up on a pastebin or something if you can't see the issue. – nneonneo Oct 25 '12 at 07:04
  • error: unrecognized command line option “-arch”. But THANK YOU I should read more - my frustration is setting in.. sometimes flusters my reasoning – Jim Oct 25 '12 at 07:18
  • It would rather make sense for you to **post an actual answer** rather than putting the answer in your question. There's a button below, maybe you could do that. – slhck Oct 25 '12 at 07:35
  • that does make sense, I'll do that if I can confirm this works in a second. – Jim Oct 25 '12 at 07:36
  • 1
    See this answer for link talking about legal issues WRT including ffmpeg in an iOS app: http://stackoverflow.com/questions/15832754/trying-to-compile-the-ffmpeg-libraries-for-iphoneos-platform-with-armv6-and-arv7/17202184#17202184 – MoDJ Jul 20 '13 at 19:28

1 Answers1

12

Here is my working Configure for cross-compiling FFmpeg on iOS 6 the arch is ARMv7

NOTE: You must have to have gas-preprocessor.pl inside /usr/local/bin/ please do not continue until you have gas-preprocessor.pl on your bin directory

  • Download FFmpeg 1.0 "Angel" from here

  • Unzip it and place it somewhere i.e. your Desktop folder

  • Open terminal and browse to unzipped FFmpeg folder

  • Copy and paste the following command, (be patient will take a while)

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

  • Now type the following command on terminal make (wait a little more)

  • Once it has finished now type on terminal sudo make install (wait again)

  • Go to /usr/local/lib to find your freshly baked armv7 libs

  • Enjoy!

Alex


Added Support for armv7s

This armv7s configure is totally untested and i dont really know if this would work, i don't own an iPhone 5 so we need someone to test the final armv7s libs

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

dalexsoto
  • 3,412
  • 1
  • 27
  • 43
  • Wow thanks you are great! I'll give it a try, does it also include ARMv7s compatibility? – Jim Oct 26 '12 at 16:25
  • nope just armv7, idk if armv7s would work but will edit question – dalexsoto Oct 26 '12 at 19:24
  • btw @Jimmy your `Mean` JS Shell is amazing :) – dalexsoto Oct 26 '12 at 21:30
  • Hi dalexsoto. Thanks for your answer, that helped me a lot! Do I need to compile two libraries? one for Armv7 and another for Armv7s? Besides the usual Armv6? Thanks again! – neowinston Dec 17 '12 at 15:16
  • 1
    @Winston Yes if you want to support newer devices processors you would need to build a fat lib i mean creating ARMv6, ARMv7 and ARMv7s and then combining them using `lipo` – dalexsoto Dec 17 '12 at 18:34
  • @Winston did you compile that lib with sdk 6.1? – Błażej Feb 05 '13 at 08:10
  • Not yet, but only with SDK 6.0, but I suppose it wouldn't be much differente. I could try. – neowinston Feb 05 '13 at 13:35
  • building with SDK 6.1 I get this: /usr/bin/ranlib: archive member: libavformat/libavformat.a(avlanguage.o) cputype (16777223) does not match previous archive members cputype (12) (all members must match) ranlib: archive member: libavformat/libavformat.a(avlanguage.o) cputype (16777223) does not match previous archive members cputype (12) (all members must match) make: *** [libavformat/libavformat.a] Error 1 – WalterF Jun 26 '13 at 15:56
  • Hi i'm getting the below error in config.log ./configure: line 693: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/lib/gcc: is a directory C compiler test failed. Please let know what's wrong ? – 2vision2 Jul 05 '13 at 13:52