Share Coding

Tutorials, Problems, Stuffs …

Building FFmpeg on XCode 4 (IOS5.0) for real iPhone only (armv7)

Using iFrameExtractor open source project for an example.
https://github.com/lajos/iFrameExtractor


1. Install macport at http://www.macports.org/install.php

2. Open terminal type:

sudo port install pkgconfig

3. Terminal type: 

git clone https://github.com/lajos/iFrameExtractor.git

cd iFrameExtractor/ffmpeg

./configure

4. Install them by using macport if the commands told you that there are any missing packages

mkdir armv7

mkdir lib

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

make

mv libavcodec/libavcodec.a armv7/

mv libavdevice/libavdevice.a armv7/

mv libavformat/libavformat.a armv7/

mv libavutil/libavutil.a armv7/

mv libswscale/libswscale.a armv7/

cp armv7/*.a lib/

5. Open iFrameExtractor.xcodeproj and run with a REAL iPhone

Advertisements

12 responses to “Building FFmpeg on XCode 4 (IOS5.0) for real iPhone only (armv7)

  1. Michelle Cannon 2012/03/01 at 8:05 am

    Interesting, you could just try our project, which works on non-jail broken iPhones

    https://github.com/mooncatventures-group

  2. Carlos 2012/04/03 at 3:42 am

    Hi and thanks for this great tutorial, I am having issues with ./config in iOS5.1, this is what I am running:

    ./configure –disable-doc –disable-ffmpeg –disable-ffplay –disable-ffserver –enable-cross-compile –arch=arm –target-os=darwin –cc=/applications/xcode.app/contents/Developer/usr/bin/gcc –as=’gas-preprocessor/gas-preprocessor.pl /applications/xcode.app/contents/Developer/usr/bin/gcc’ –sysroot=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk –cpu=cortex-a8 –extra-cflags=’-arch armv7′ –extra-ldflags=’-arch armv7 -isysroot /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk’ –enable-pic

    And I am getting this error message:

    /applications/xcode.app/contents/Developer/usr/bin/gcc is unable to create an executable file.
    C compiler test failed.

    If you think configure made a mistake, make sure you are using the latest
    version from SVN. If the latest version fails, report the problem to the
    ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.err” produced by configure as this will help
    solving the problem.

    What could be the problem?

    Thanks in advance..

    • Mr.Sing 2012/04/03 at 2:24 pm

      Try this config:

      ./configure –disable-doc –disable-ffmpeg –disable-ffplay –disable-ffserver –enable-cross-compile –arch=arm –target-os=darwin –cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc –as=’gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc’ –sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk –cpu=cortex-a8 –extra-cflags=’-arch armv7′ –extra-ldflags=’-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk’ –enable-pic

      • Carlos 2012/04/03 at 8:34 pm

        Thanks for your help Mr.Sing, this is the error that I got running your suggested command:

        Unknown C compiler /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
        /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc is unable to create an executable file.
        C compiler test failed.

  3. maxi1mapps 2012/05/27 at 4:01 pm

    Has anyone got this errors?

    “_BZ2_bzDecompress”, referenced from:
    _matroska_decode_buffer in libavformat.a(matroskadec.o)
    “_BZ2_bzDecompressEnd”, referenced from:
    _matroska_decode_buffer in libavformat.a(matroskadec.o)
    “_BZ2_bzDecompressInit”, referenced from:
    _matroska_decode_buffer in libavformat.a(matroskadec.o)

    I saw on forums that the solution is to add -lbz2 flag to the linker, but I don’t know how&where to add it.

    • nixonjan 2012/06/17 at 4:17 pm

      I have the same error – do you find correct solution ?

    • Chris Trahey 2012/07/05 at 2:57 pm

      I had similar errors, and did this to solve (Xcode 4.3.3):
      Select the project in the navigator, and in the main area select your target, then ‘summary’. There is a section called “linked Frameworks and Libraries”. Click the little + button and use the search. I added libz.dylib and libbz2.1.0.dylib
      Good luck!

    • SG 2013/03/13 at 5:17 pm

      I just added “libbz2.1.0.dylib” to the ‘Linked Frameworks and Libraries’ and the errors were removed.

  4. sivasankar 2012/10/18 at 12:41 pm

    How to compile for ios5.1 with xcode4.4

  5. sivasankar 2012/10/18 at 12:42 pm

    i tried this ——- ./configure –disable-doc –disable-ffmpeg –disable-ffplay –disable-ffserver –enable-cross-compile –arch=arm –target-os=darwin –cc=/Applications/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc –as=’gas-preprocessor/gas-preprocessor.pl /Applications/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc’ –sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk –cpu=cortex-a8 –extra-cflags=’-arch armv7′ –extra-ldflags=’-arch armv7 -isysroot /Applications/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk’ –enable-pic

  6. sivasankar 2012/10/18 at 12:43 pm

    the error is——Unknown C compiler /Applications/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
    /Applications/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc is unable to create an executable file.
    C compiler test failed.

  7. Dave 2012/10/25 at 7:20 pm

    Here is how i built the project for ios5

    ## Introduction ##

    This project is forked from .
    I update the code for the latest ffmpeg and iOS version. The source code is tested on `Mac OS 10.7.4(Lion)` for `ffmpeg 0.11.1` and `iOS 5.1` with `Xcode 4.3.2`.

    ## Build steps ##

    – Download the code using

    `git clone git://github.com/PinkyJie/iFrameExtractor.git`

    – Download the latest ffmpeg (0.11.1 tested) using

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

    – Put the ffmpeg source code into the folder `ffmpeg`

    – Copy the perl script `gas-preprocessor.pl` into `/usr/local/bin` folder

    – Change directory to your `ffmpeg` folder, select your target platform and follow the scripts below

    ### Platforms ###

    – `armv7` (for iPhone 3GS and devices after 3GS)

    ##### configure #####

    >./configure \

    >–cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \

    >–as=’/usr/local/bin/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/iPhoneOS5.1.sdk \

    >–target-os=darwin \

    >–arch=arm \

    >–cpu=cortex-a8 \

    >–extra-cflags=’-arch armv7′ \

    >–extra-ldflags=’-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk’ \

    >–prefix=compiled/armv7 \

    >–enable-cross-compile \

    >–enable-nonfree \

    >–enable-gpl \

    >–disable-armv5te \

    >–disable-swscale-alpha \

    >–disable-doc \

    >–disable-ffmpeg \

    >–disable-ffplay \

    >–disable-ffprobe \

    >–disable-ffserver \

    >–disable-asm \

    >–disable-debug

    ##### make #####

    >make clean

    >make && make install

    – `armv6` (for devices before 3GS)

    ##### configure #####

    >./configure \

    >–cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \

    >–as=’/usr/local/bin/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/iPhoneOS5.1.sdk \

    >–target-os=darwin \

    >–arch=arm \

    >–cpu=arm1176jzf-s \

    >–extra-cflags=’-arch armv6′ \

    >–extra-ldflags=’-arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk’ \

    >–prefix=compiled/armv6 \

    >–enable-cross-compile \

    >–enable-nonfree \

    >–enable-gpl \

    >–disable-armv5te \

    >–disable-swscale-alpha \

    >–disable-doc \

    >–disable-ffmpeg \

    >–disable-ffplay \

    >–disable-ffprobe \

    >–disable-ffserver \

    >–disable-asm \

    >–disable-debug

    ##### make #####

    >make clean

    >make && make install

    – `i386` (for simulator)

    ##### configure #####

    >./configure \

    >–cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \

    >–as=’/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc’ \

    >–sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \

    >–target-os=darwin \

    >–arch=i386 \

    >–cpu=i386 \

    >–extra-cflags=’-arch i386′ \

    >–extra-ldflags=’-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk’ \

    >–prefix=compiled/i386 \

    >–enable-cross-compile \

    >–enable-nonfree \

    >–enable-gpl \

    >–disable-armv5te \

    >–disable-swscale-alpha \

    >–disable-doc \

    >–disable-ffmpeg \

    >–disable-ffplay \

    >–disable-ffprobe \

    >–disable-ffserver \

    >–disable-asm \

    >–disable-debug

    ##### make #####

    >make clean

    >make && make install

    – `universal` (using one *.a files for all platforms)

    >mkdir -p ./compiled/fat/lib

    >lipo -output ./compiled/fat/lib/libavcodec.a -create \

    >-arch armv6 ./compiled/armv6/lib/libavcodec.a \

    >-arch armv7 ./compiled/armv7/lib/libavcodec.a \

    >-arch i386 ./compiled/i386/lib/libavcodec.a

    >lipo -output ./compiled/fat/lib/libavdevice.a -create \

    >-arch armv6 ./compiled/armv6/lib/libavdevice.a \

    >-arch armv7 ./compiled/armv7/lib/libavdevice.a \

    >-arch i386 ./compiled/i386/lib/libavdevice.a

    >lipo -output ./compiled/fat/lib/libavformat.a -create \

    >-arch armv6 ./compiled/armv6/lib/libavformat.a \

    >-arch armv7 ./compiled/armv7/lib/libavformat.a \

    >-arch i386 ./compiled/i386/lib/libavformat.a

    >lipo -output ./compiled/fat/lib/libavutil.a -create \

    >-arch armv6 ./compiled/armv6/lib/libavutil.a \

    >-arch armv7 ./compiled/armv7/lib/libavutil.a \

    >-arch i386 ./compiled/i386/lib/libavutil.a

    >lipo -output ./compiled/fat/lib/libswresample.a -create \

    >-arch armv6 ./compiled/armv6/lib/libswresample.a \

    >-arch armv7 ./compiled/armv7/lib/libswresample.a \

    >-arch i386 ./compiled/i386/lib/libswresample.a

    >lipo -output ./compiled/fat/lib/libpostproc.a -create \

    >-arch armv6 ./compiled/armv6/lib/libpostproc.a \

    >-arch armv7 ./compiled/armv7/lib/libpostproc.a \

    >-arch i386 ./compiled/i386/lib/libpostproc.a

    >lipo -output ./compiled/fat/lib/libswscale.a -create \

    >-arch armv6 ./compiled/armv6/lib/libswscale.a \

    >-arch armv7 ./compiled/armv7/lib/libswscale.a \

    >-arch i386 ./compiled/i386/lib/libswscale.a

    >lipo -output ./compiled/fat/lib/libavfilter.a -create \

    >-arch armv6 ./compiled/armv6/lib/libavfilter.a \

    >-arch armv7 ./compiled/armv7/lib/libavfilter.a \

    >-arch i386 ./compiled/i386/lib/libavfilter.a

    #### The complied static libraries (*.a) lie in the`ffmpeg/compiled` folder. ####

    also need to

    Select the project in the navigator, and in the main area select your target, then ‘summary’. There is a section called “linked Frameworks and Libraries”. Click the little + button and use the search. I added libz.dylib and libbz2.1.0.dylib

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: