Compile the FFMPEG static library for iOS on a Mac computer (Successful Experience). If you have any questions, leave a message.

Source: Internet
Author: User

First of all, I believe you already have FFMPEG, not much nonsense, you still need another file, gas-preprocessor.pl this file I believe you will try your best to find, after everything has, next let's start compiling.

1. Open the terminal and CD to the directory where FFmpeg is located. For example: CD/users/Apple/documents/FFMPEG, press enter,

Here I have compiled three copies: i386, armv7, and armv7s. If you need the armv6 framework, you can try to compile it by yourself. After all, few people are using it now.

Okay! 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'

Enter the above sentence and press Enter. After the operation is successful, a message similar to the following will appear:

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 $

In this case, the configuration is complete, and then make enter. The last example is as follows:

Strip ffprobe
Localhost: FFMPEG Apple $

Then, make install is successful, and now you can copy the compiled static library to another place to save it. Similar to the following:

CP libavcodec/libavcodec. A./lib/i386/libavcodec.

In this way, you copy the libavcodec. A library to the i386 folder. After you copy all the required libraries, you can clear the compiled libraries in the current directory.

Run the make clean command. Next, you can compile armv7 in accordance with this method, with the armv7s framework.

The specific configuration has been written:

// In 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'

// In 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'

// Modify .. The above is compiled under xcode4.5.2, And I successfully compiled under xcode4.6:

// I386

. /Configure -- cc =/applications/xcode. APP/contents/developer/platforms/iphonesimulator. platform/developer/usr/bin/GCC -- As = '. /gas-preprocessor.pl/applications/xcode. APP/contents/developer/platforms/iphonesimulator. platform/developer/usr/bin/GCC '-- extra-ldflags =-L/applications/xcode. APP/contents/developer/platforms/iphonesimulator. platform/developer/sdks/iphonesimulator6.1.sdk/usr/lib/System
-- Sysroot =/applications/xcode. APP/contents/developer/platforms/iphonesimulator. platform/developer/sdks/iphonesimulator6.1.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'

// ARM7

. /Configure -- cc =/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/usr/bin/GCC -- As = '. /gas-preprocessor.pl/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/usr/bin/GCC '-- extra-ldflags ='-arch armv7
-Isysroot/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/sdks/iphoneos6.1.sdk '-- sysroot =/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/sdks/iphoneos6.1.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'

// Arm6
// Arm7s

. /Configure -- cc =/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/usr/bin/GCC -- As = '. /gas-preprocessor.pl/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/usr/bin/GCC '-- extra-ldflags ='-arch armv7s
-Isysroot/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/sdks/iphoneos6.1.sdk '-- sysroot =/applications/xcode. APP/contents/developer/platforms/iphoneos. platform/developer/sdks/iphoneos6.1.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'

If you have compiled all the libraries under the three frameworks, it means that you have been quite successful, just one step away, that is, merging the libraries of the three versions into one, it can be used in any framework.

This way

// Merge

Lipo-create lib/i386/libavcodec. A lib/ARM7/libavcodec. A lib/arm7s/libavcodec. A-output lib/libavcodec.
Lipo-create lib/i386/libavformat. A lib/ARM7/libavformat. A lib/arm7s/libavformat. A-output lib/libavformat.
Lipo-create lib/i386/libavdevice. A lib/ARM7/libavdevice. A lib/arm7s/libavdevice. A-output lib/libavdevice.
Lipo-create lib/i386/libavutil. A lib/ARM7/libavutil. A lib/arm7s/libavutil. A-output lib/libavutil.
Lipo-create lib/i386/libswscale. A lib/ARM7/libswscale. A lib/arm7s/libswscale. A-output lib/libswscale.

All the paths here are compiled on my computer, specific to each computer, if the path is different, you just need to change it. Then, when compiling, The xcode version is 4.5.2, so I wrote xcode4.5.2.app, which is used in many places in the path, depending on the actual situation.

In addition, I have never understood the usefulness of make install in one step. From the Internet, I used it in many places, but it seems that skip this step will not have any problems. When it is okay, I can compile it and increase confidence. Finally, I wish you success .!!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.