I'm trying to compile the ffmpeg by using the make and build files in iFrameExtractor example. firstly i tried to follow the readme file on the github, which only says to run the ./build_universal in ffmpeg folder. it did not work
i then tried to follow the info in INSTALL without success. i then tried doing the stuff in INSTALL followed by the ./build_universal which didn't work. All the *.a files that are imported to the project exists until the end of the build sequence. when the lipo commands in build_universal are run, which i guess concat the .a files for the different architectures(?). anyhow these leave the following errors:
lipo: specifed architecture type (armv6) for file (armv6/libavcodec.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavdevice.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavformat.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavutil.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libswscale.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
i can get the project to compile for simulator if i only use ./build_armv7 but if i run the universal the .a files are removed in the end. and only using doesn't work to build for iphone 4 .
After a week of trial and error, I was finally able to create the ffmpeg universal libraries and successfully compile and run iFrameExtractor for the device as well as the simulator.
To compile and run the project on your iPhone device OR simulator:
1) open Terminal
2) clone the repository: git clone git://github.com/lajos/iFrameExtractor.git
3) go to the ffmpeg folder in the project: cd iFrameExtractor/ffmpeg
4) run: ./configure
5) Edit the build scripts (build_armv6, build_armv7, build_i386) as follows:
These scripts assume you are using iOS SDK 5.0 on Xcode 4.2.
build_armv6:
#!/bin/tcsh -f
if (! -d armv6) mkdir armv6
if (! -d lib) mkdir lib
rm armv6/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--enable-cross-compile --target-os=darwin \
--arch=arm --cpu=arm1176jzf-s \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
--extra-ldflags="-arch armv6 -L//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \
--extra-cflags="-arch armv6"
make
mv libavcodec/libavcodec.a armv6/
mv libavdevice/libavdevice.a armv6/
mv libavformat/libavformat.a armv6/
mv libavutil/libavutil.a armv6/
mv libswscale/libswscale.a armv6/
rm lib/*.a
cp armv6/*.a lib/
build_armv7:
#!/bin/tcsh -f
if (! -d armv7) mkdir armv7
if (! -d lib) mkdir lib
rm armv7/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--enable-cross-compile --target-os=darwin \
--arch=arm --cpu=cortex-a8 --enable-pic \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
--extra-ldflags="-arch armv7 - L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \
--extra-cflags="-arch armv7"
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/
rm lib/*.a
cp armv7/*.a lib/
build_i386:
#!/bin/tcsh -f
if (! -d i386) mkdir i386
if (! -d lib) mkdir lib
rm i386/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--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/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk \
--extra-ldflags="-arch i386 -L//Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system" \
--extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2"
make
mv libavcodec/libavcodec.a i386/
mv libavdevice/libavdevice.a i386/
mv libavformat/libavformat.a i386/
mv libavutil/libavutil.a i386/
mv libswscale/libswscale.a i386/
rm lib/*.a
cp i386/*.a lib/
6) build the ffmpeg libraries: ./build_universal
7) open the xcode project and run it on your iPhone device or simulator
These steps work perfectly for me. I hope this will help others struggling to get the ffmpeg libraries working for iOS.
i downloaded the latest ffmpeg repository and used the following to compile only for armv6 and armv7. I couldn't get it working for i386, i receive errors that the cputype and subcputype are wrong. apparently the cputype is supposed to be x86 and subcputype should be intel.
anyhow i used the following build scripts to compile for the arm architectures:
build script:
#!/bin/sh
set -e
SCRIPT_DIR=$( (cd -P $(dirname $0) && pwd) )
DIST_DIR_BASE=${DIST_DIR_BASE:="$SCRIPT_DIR/dist"}
if [ -d ffmpeg ]
then
echo "Found ffmpeg source directory, no need to fetch from git..."
else
echo "Fetching ffmpeg from git://git.videolan.org/ffmpeg.git..."
git clone git://git.videolan.org/ffmpeg.git
fi
ARCHS=${ARCHS:-"armv6 armv7"}
for ARCH in $ARCHS
do
FFMPEG_DIR=ffmpeg-$ARCH
if [ -d $FFMPEG_DIR ]
then
echo "Removing old directory $FFMPEG_DIR"
rm -rf $FFMPEG_DIR
fi
echo "Copying source for $ARCH to directory $FFMPEG_DIR"
cp -a ffmpeg $FFMPEG_DIR
cd $FFMPEG_DIR
DIST_DIR=$DIST_DIR_BASE-$ARCH
mkdir -p $DIST_DIR
case $ARCH in
armv6)
EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=arm1176jzf-s"
EXTRA_CFLAGS="-arch $ARCH"
EXTRA_LDFLAGS="-arch $ARCH"
;;
armv7)
EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=cortex-a8 --enable-pic"
EXTRA_CFLAGS="-arch $ARCH"
EXTRA_LDFLAGS="-arch $ARCH"
;;
x86_64)
EXTRA_CC_FLAGS="-mdynamic-no-pic"
;;
esac
echo "Configuring ffmpeg for $ARCH..."
./configure \
--prefix=$DIST_DIR \
--extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/system \
--disable-bzlib \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk \
--extra-ldflags="$EXTRA_LDFLAGS" \
--extra-cflags="$EXTRA_CFLAGS" \
$EXTRA_FLAGS
echo "Installing ffmpeg for $ARCH..."
make && make install
cd $SCRIPT_DIR
if [ -d $DIST_DIR/bin ]
then
rm -rf $DIST_DIR/bin
fi
if [ -d $DIST_DIR/share ]
then
rm -rf $DIST_DIR/share
fi
done
and combine libs script:
#!/bin/bash
set -e
ARCHS="armv6 armv7"
for ARCH in $ARCHS
do
if [ -d dist-$ARCH ]
then
MAIN_ARCH=$ARCH
fi
done
if [ -z "$MAIN_ARCH" ]
then
echo "Please compile an architecture"
exit 1
fi
OUTPUT_DIR="dist-uarch"
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/lib $OUTPUT_DIR/include
for LIB in dist-$MAIN_ARCH/lib/*.a
do
LIB=`basename $LIB`
LIPO_CREATE=""
for ARCH in $ARCHS
do
if [ -d dist-$ARCH ]
then
LIPO_CREATE="$LIPO_CREATE-arch $ARCH dist-$ARCH/lib/$LIB "
fi
done
OUTPUT="$OUTPUT_DIR/lib/$LIB"
echo "Creating: $OUTPUT"
lipo -create $LIPO_CREATE -output $OUTPUT
lipo -info $OUTPUT
done
echo "Copying headers from dist-$MAIN_ARCH..."
cp -R dist-$MAIN_ARCH/include/* $OUTPUT_DIR/include
then i import the .a files from BUILD-FOLDER/dist-uarch and it builds in xcode like a charm!
building FFMPEG for iOS 5.1
hope this will help you to build latest FFMPEG for iOS 5.1
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./build_universal
note: you have to create build_* scripts first, to do this see code below
script for ARMV7 - create file build_armv7
#!/bin/tcsh -f
if (! -d armv7) mkdir armv7
if (! -d lib) mkdir lib
rm armv7/*.a
make clean
./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.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 --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
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/
rm lib/*.a
cp armv7/*.a lib/
script for ARMV6 - create file build_armv6
#!/bin/tcsh -f
if (! -d armv6) mkdir armv6
if (! -d lib) mkdir lib
rm armv6/*.a
make clean
./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.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 --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'
make
mv libavcodec/libavcodec.a armv6/
mv libavdevice/libavdevice.a armv6/
mv libavformat/libavformat.a armv6/
mv libavutil/libavutil.a armv6/
mv libswscale/libswscale.a armv6/
rm lib/*.a
cp armv6/*.a lib/
script for simulator - create file build_i386
#!/bin/tcsh -f
if (! -d i386) mkdir i386
if (! -d lib) mkdir lib
rm i386/*.a
make clean
./configure \
--disable-bzlib --disable-doc \
--disable-ffmpeg --disable-ffplay \
--disable-ffserver --disable-mmx \
--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' \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \
--extra-ldflags="-arch i386 -L//Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/lib/system" \
--extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2"
make
mv libavcodec/libavcodec.a i386/
mv libavdevice/libavdevice.a i386/
mv libavformat/libavformat.a i386/
mv libavutil/libavutil.a i386/
mv libswscale/libswscale.a i386/
rm lib/*.a
cp i386/*.a lib/
script for universal build (will merge libraries into one universal) - create file build_universal
#!/bin/tcsh -f
source ./build_armv6
source ./build_armv7
source ./build_i386
if (! -d universal) mkdir universal
if (! -d lib) mkdir lib
rm universal/*.a
lipo -create -arch armv6 armv6/libavcodec.a -arch armv7 armv7/libavcodec.a -arch i386 i386/libavcodec.a -output universal/libavcodec.a
lipo -create -arch armv6 armv6/libavdevice.a -arch armv7 armv7/libavdevice.a -arch i386 i386/libavdevice.a -output universal/libavdevice.a
lipo -create -arch armv6 armv6/libavformat.a -arch armv7 armv7/libavformat.a -arch i386 i386/libavformat.a -output universal/libavformat.a
lipo -create -arch armv6 armv6/libavutil.a -arch armv7 armv7/libavutil.a -arch i386 i386/libavutil.a -output universal/libavutil.a
lipo -create -arch armv6 armv6/libswscale.a -arch armv7 armv7/libswscale.a -arch i386 i386/libswscale.a -output universal/libswscale.a
rm lib/*.a
cp universal/*.a lib/
Related
When i compile librtmp for ios, the script shows below:
#!/bin/sh
# OS X Yosemite, Xcode 6.1
set -ex
DEVELOPER="/Applications/Xcode.app/Contents/Developer"
DEVICE_SDK="$DEVELOPER/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
SIMULATOR_SDK="$DEVELOPER/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
CURRPATH=`pwd`
SOURCE="rtmpdump"
DSTDIR="librtmp"
LIBSSL=`cd ../OpenSSL/libssl;pwd`
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DSTDIR
mkdir $DSTDIR
if [ ! -d $SOURCE ]; then
git clone git://git.ffmpeg.org/rtmpdump $SOURCE
else
cd $SOURCE
git fetch
cd ..
fi
cd $SOURCE/librtmp
for ARCH in $ARCHS; do
mkdir -p ../$DSTDIR/$ARCH
if [[ $ARCH == arm* ]]; then
SDK=$DEVICE_SDK
else
SDK=$SIMULATOR_SDK
fi
perl -i -pe 's|^AR=\$\(CROSS_COMPILE\)ar|AR=xcrun ar|' Makefile
CROSS_COMPILE="$DEVELOPER/usr/bin/" \
XCFLAGS="-O0 -isysroot $SDK -I$LIBSSL/include -arch $ARCH " \
XLDFLAGS="-isysroot $SDK -L$LIBSSL/lib -arch $ARCH -miphoneos-version-min=7.0 " \
make SYS=darwin
make SYS=darwin prefix="$CURRPATH/$DSTDIR/$ARCH" install
make clean
done
mkdir -p $CURRPATH/$DSTDIR/lib
cd $CURRPATH/$DSTDIR/$ARCH/lib
LIBS=`ls *.a`
cd $CURRPATH
for LIB in $LIBS; do
lipo -create `find $DSTDIR -name $LIB` -output $DSTDIR/lib/$LIB
done
cp -rf $DSTDIR/$ARCH/include $DSTDIR
for ARCH in $ARCHS; do
rm -rf $DSTDIR/$ARCH
done
when statement make SYS=darwin runs, error shows:
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc -Wall -O0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I/Users/Smeegol/Desktop/AVCodecs2/OpenSSL/libssl/include -arch armv7 -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o rtmp.o rtmp.c
clang: error: invalid version number in '-miphoneos-version-min=.sd'
make: *** [rtmp.o] Error 1
Why? I have set XLDFLAGS="-isysroot $SDK -L$LIBSSL/lib -arch $ARCH -miphoneos-version-min=7.0 " and why invalid version number in '-miphoneos-version-min=.sd' occurs?
I had the same problem and resolved it by changing the -isysroot argument from:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
to:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk
Note that the latter is a symlink to the former on my system.
It appears that clang is implicitly setting -miphoneos-version-min= from the iPhoneOSXXX.sdk directory name. Using the link with the version number in it seems to fix the compilation issue.
Environment: Mac OS X 10.9.2, Xcode 5.1.
I have compiled librtmp, libogg and libspeex successfully, they are in the directories named fat-librtmp, fat-libogg and fat-libspeex , then I run the shell script as below to coompile them into FFmpeg:
#!/bin/sh
# OS X Mavericks, Xcode 5.1
set -ex
VERSION="2.2.2"
CURRPATH=`pwd`
DSTDIR="ffmpeg-built"
SCRATCH="scratch"
LIBRTMP=$CURRPATH/librtmp
ARCHS="i386 x86_64 armv7 armv7s arm64"
CONFIGURE_FLAGS="--enable-shared \
--disable-doc \
--disable-stripping \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-ffprobe \
--disable-decoders \
--disable-encoders \
--disable-protocols \
--enable-protocol=file \
--enable-protocol=rtmp \
--enable-librtmp \
--enable-encoder=flv \
--enable-decoder=flv \
--disable-symver \
--disable-asm \
--enable-cross-compile"
rm -rf $DSTDIR
mkdir $DSTDIR
if [ ! `which yasm` ]; then
if [ ! `which brew` ]; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
fi
brew install yasm
fi
if [ ! `which gas-preprocessor.pl` ]; then
curl -3L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl -o /usr/local/bin/gas-preprocessor.pl
chmod +x /usr/local/bin/gas-preprocessor.pl
fi
if [ ! -e ffmpeg-$VERSION.tar.bz2 ]; then
curl -O http://www.ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2
fi
tar jxf ffmpeg-$VERSION.tar.bz2
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
for ARCH in $ARCHS; do
mkdir -p $DSTDIR/$SCRATCH/$ARCH
cd $DSTDIR/$SCRATCH/$ARCH
CFLAGS="-arch $ARCH"
if [ $ARCH == "i386" -o $ARCH == "x86_64" ]; then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=6.0"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=6.0"
if [ $ARCH == "arm64" ]; then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CFLAGS="$CFLAGS -I$LIBRTMP/include"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS -L$LIBRTMP/lib"
$CURRPATH/ffmpeg-$VERSION/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix=$CURRPATH/$DSTDIR/$ARCH
make -j3 install $EXPORT
cd $CURRPATH
done
rm -rf $DSTDIR/$SCRATCH
mkdir -p $DSTDIR/lib
cd $DSTDIR/$ARCH/lib
LIBS=`ls *.a`
cd $CURRPATH
for LIB in $LIBS; do
lipo -create `find $DSTDIR -name $LIB` -output $DSTDIR/lib/$LIB
done
cp -rf $DSTDIR/$ARCH/include $DSTDIR
for ARCH in $ARCHS; do
rm -rf $DSTDIR/$ARCH
done
Unluckily, the config.log shows:
check_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
pkg-config --exists --print-errors librtmp
Package librtmp was not found in the pkg-config search path.
Perhaps you should add the directory containing `librtmp.pc'
to the PKG_CONFIG_PATH environment variable
No package 'librtmp' found
ERROR: librtmp not found
I have googled and knew that configure contains a line enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket, which maybe be wrong. Right? Can somebody help me to solve it?
UPDATE at 2014/06/10
I think it's about pkgconfig or something, so I have create a file named librtmp.pc at /usr/local/lib/pkgconfig, which contains below text:
prefix=/usr/local/librtmp
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: librtmp
Description: RTMP implementation
Version: v2.3
Requires:
URL: http://rtmpdump.mplayerhq.hu
Libs: -L${libdir} -lrtmp -lz
Cflags: -I${includedir}
Also I have moved built librtmp to /usr/local. After above being done, I run the shell script again, but still same error! Can somebody told me why and how to solve it?
The below links give some insight while building ffmpeg.
https://trac.ffmpeg.org/wiki/CompilationGuide/Generic
Check whether LD_LIBRARY_PATH environment variable is set properly.
Environment: Mac OS X 10.9.2, Xcode 5.1. Build shell scripts as below:
#!/bin/sh
# OS X 10.9.2, Xcode 5.1
set -ex
VERSION="2.2.1"
SDKVERSION="7.1"
BUILDDIR=`pwd`
DESTDIR="ffmpeg-built"
OUTPUTDIR="dependencies"
DEVELOPER=`xcode-select -print-path`
GASPREPROCESSOR="gas-preprocessor.pl"
ARCHS="i386 x86_64 armv7 armv7s arm64"
cp $GASPREPROCESSOR /usr/local/bin
rm -rf $DESTDIR
mkdir $DESTDIR
rm -rf $OUTPUTDIR
mkdir $OUTPUTDIR
mkdir -p $OUTPUTDIR/bin
mkdir -p $OUTPUTDIR/include
mkdir -p $OUTPUTDIR/lib
if [ ! -e "ffmpeg-$VERSION.tar.bz2" ]; then
curl -LO http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2
fi
tar jxf ffmpeg-$VERSION.tar.bz2
cd "ffmpeg-$VERSION"
set +e
CCACHE=`which ccache`
if [ $? == "0" ]; then
CCACHE="$CCACHE "
else
CCACHE=""
fi
set -e
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
make distclean
IOSMV="-miphoneos-version-min=4.3"
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
CONFIG="--disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile"
if [ "$ARCH" == "i386" ];
then
PLATFORM="iPhoneSimulator"
EXTRA_CONFIG="--arch=i386 --target-os=darwin --cpu=i386 --disable-asm --enable-pic"
EXTRA_CFLAGS="-arch i386"
EXTRA_LDFLAGS="-I$DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk/usr/lib -mfpu=neon"
else
PLATFORM="iPhoneOS"
EXTRA_CONFIG="--arch=arm --target-os=darwin --cpu=cortex-a8 --disable-armv5te --enable-pic"
EXTRA_CFLAGS="-w -arch $ARCH -mfpu=neon"
EXTRA_LDFLAGS="-mfpu=neon"
fi
./configure --prefix=$BUILDDIR/$DESTDIR/$ARCH --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-iconv --disable-bzlib --enable-avresample --sysroot="$DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk" --cc="$DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" --as='/usr/local/bin/$GASPREPROCESSOR' --extra-cflags="$EXTRA_CFLAGS -miphoneos-version-min=$SDKVERSION -I$BUILDDIR/$OUTPUTDIR/include" --extra-ldflags="-arch $ARCH $EXTRA_LDFLAGS -isysroot $DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk -miphoneos-version-min=$SDKVERSION -L$BUILDDIR/$OUTPUTDIR/lib" $EXTRA_CONFIG --enable-pic --extra-cxxflags="$CPPFLAGS -I$BUILDDIR/$OUTPUTDIR/include -isysroot $DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk"
make
make install
done
make distclean
cd ..
mkdir -p $DESTDIR/universal/lib
cd $DESTDIR/i386/lib
for FILE in *.a;
do
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/$FILE"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/$FILE
done
But terminal logs that:
+ VERSION=2.2.1
+ SDKVERSION=7.1
++ pwd
+ BUILDDIR=/Users/Smeegol/Desktop/FFmpeg
+ DESTDIR=ffmpeg-built
++ xcode-select -print-path
+ DEVELOPER=/Applications/Xcode.app/Contents/Developer
+ ARCHS='i386 x86_64 armv7 armv7s arm64'
+ rm -rf ffmpeg-built
+ mkdir ffmpeg-built
+ '[' '!' -e ffmpeg-2.2.1.tar.bz2 ']'
+ tar jxf ffmpeg-2.2.1.tar.bz2
+ cd ffmpeg-2.2.1
+ set +e
++ which ccache
+ CCACHE=
+ '[' 1 == 0 ']'
+ CCACHE=
+ set -e
+ for ARCH in '$ARCHS'
+ mkdir -p ../ffmpeg-built/i386
+ IOSMV=-miphoneos-version-min=4.3
+ '[' i386 == arm64 ']'
+ CONFIG='--disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile'
+ '[' i386 == i386 ']'
+ PLATFORM=iPhoneSimulator
+ EXTRA_CONFIG='--arch=i386 --target-os=darwin --cpu=i386 --enable-pic --disable-asm'
+ EXTRA_CFLAGS='-arch i386 -mfpu=neon -miphoneos-version-min=4.3'
+ ./configure --prefix=/Users/Smeegol/Desktop/FFmpeg/ffmpeg-built/i386 --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk --cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --extra-cflags=-arch i386 -mfpu=neon -miphoneos-version-min=4.3 '--extra-ldflags=-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -miphoneos-version-min=4.3' --arch=i386 --target-os=darwin --cpu=i386 --enable-pic --disable-asm
Unknown option "i386".
See ./configure --help for available options.
Why Unknown option "i386".?
--extra-cflags=-arch i386 -mfpu=neon -miphoneos-version-min=4.3
Two things seem wrong here.
First, the config.log is showing that --extra-cflags=<args> is not getting escaped properly. Thus, FFmpeg's ./configure script is seeing --extra-cflags=-arch, i386, -mfpu=neon; i386 alone is not a valid flag for the script, so it fails.
You can compare your script to the one I maintain on github. I wonder what happens if you use variable expansions in the script, instead of variable replacement? e.g.
--extra-cflags="$EXTRA_CFLAGS -miphoneos-versi....
... try:
--extra-cflags="${EXTRA_CFLAGS} -miphoneos-versi....
Second, -mfpu=neon and -arch i386 together don't make sense. It looks like this script is going through the branch of the big if statement that contains PLATFORM="iPhoneOS", and not PLATFORM="iPhoneSimulator". That's just not going to work.
So, I'm not 100% sure of the fix, but those are some of your problems.
See also: Compile libogg for iOS using Xcode5.1 error
Environment: Mac OS X 10.9.2, Xcode 5.1.
There are two shell scripts to build libogg and libspeex, where locates in the same directory. The libogg build scripts is as below:
#!/bin/sh
set -xe
VERSION="1.3.1"
BUILDDIR=`pwd`
DESTDIR="libogg-built"
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DESTDIR
mkdir $DESTDIR
if [ ! -e "libogg-$VERSION.zip" ]; then
curl -LO http://downloads.xiph.org/releases/ogg/libogg-$VERSION.zip
fi
unzip -oq libogg-$VERSION.zip
cd libogg-$VERSION
./configure
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
make distclean
IOSMV="-miphoneos-version-min=4.3"
case $ARCH in
arm*)
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
SDK=`xcodebuild -version -sdk iphoneos Path` \
CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
LDFLAGS="-Wl,-syslibroot,$SDK" \
./configure \
--host=arm-apple-darwin \
--prefix=$BUILDDIR/$DESTDIR/$ARCH
;;
*)
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=$BUILDDIR/$DESTDIR/$ARCH
;;
esac
make
make install
done
make distclean
cd ..
mkdir -p $DESTDIR/universal/lib
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/libogg.a"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a
Run scripts in the terminal, and libogg was successfully compiled. Then Run the libspeex scripts as below:
#!/bin/sh
set -xe
VERSION="1.2rc1"
BUILDDIR=`pwd`
OGGDIR="libogg-built"
DESTDIR="libspeex-built"
LIBS="libspeex.a libspeexdsp.a"
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DESTDIR
mkdir $DESTDIR
if [ ! -e "speex-$VERSION.tar.gz" ]; then
curl -LO http://downloads.xiph.org/releases/speex/speex-$VERSION.tar.gz
fi
tar zxf speex-$VERSION.tar.gz
cd speex-$VERSION
./configure
for ARCH in $ARCHS;
do
mkdir -p ../$DESTDIR/$ARCH
make distclean
IOSMV="-miphoneos-version-min=4.3"
case $ARCH in
arm*)
if [ $ARCH == "arm64" ]; then
IOSMV="-miphoneos-version-min=7.0"
fi
PATH=`xcodebuild -version -sdk iphoneos PlatformPath`"/Developer/usr/bin:$PATH" \
SDK=`xcodebuild -version -sdk iphoneos Path` \
CC="xcrun --sdk iphoneos clang -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
CXX="xcrun --sdk iphoneos clang++ -arch $ARCH $IOSMV --sysroot=$SDK -isystem $SDK/usr/include" \
LDFLAGS="-Wl,-syslibroot,$SDK" \
./configure \
--host=arm-apple-darwin \
--prefix=$BUILDDIR/$DESTDIR/$ARCH \
--with-ogg=$BUILDDIR/$OGGDIR/$ARCH
;;
*)
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=$BUILDDIR/$DESTDIR/$ARCH \
--with-ogg=$BUILDDIR/$OGGDIR/$ARCH
;;
esac
make
make install
done
make distclean
cd ..
mkdir -p $DESTDIR/universal/lib
for LIB in $LIBS;
do
INPUT=""
for ARCH in $ARCHS;
do
INPUT="$INPUT $DESTDIR/$ARCH/lib/$LIB"
done
lipo -create $INPUT -output $DESTDIR/universal/lib/$LIB
done
It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!
It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!
It references /Users/Smeegol/Desktop/Speex/libogg-built/i386, and yet in the previous step ...
lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a
... I see universal in the path name, for one.
Your output directory for the libogg install should look something like this:
${OGGDIR}/lib/libogg.a
${OGGDIR}/include/<include files here>
And finally, you have a similar error to your other question:
PATH=`xcodebuild -version -sdk iphonesimulator PlatformPath`"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
--prefix=$BUILDDIR/$DESTDIR/$ARCH
--with-ogg=$BUILDDIR/$OGGDIR/$ARCH
... you are missing a "\" after the --prefix line.
You can refer to https://github.com/firstfan/libspeex-iOS
It compiles OK with latest SDK and latest speex code
It works out-of-box.
Has anyone been able to compile ffmpeg libraries using the iOS5 sdk? I have found scripts that use the 4.3 sdk but nothing for iOS5. I would assume that libraries built with the old sdk and armv7 will still be compatible for iOS 5.
Here is the command I am trying to use:
./configure \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \ --extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system \ --target-os=darwin \ --arch=arm \ --cpu=cortex-a8 \ --extra-cflags='-arch armv7' \ --extra-ldflags='-arch armv7' \ --prefix=compiled/armv7 \ --enable-pic \ --enable-cross-compile \ --disable-armv5te \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --disable-ffprobe \ --disable-doc
I have also tried using a script like this one:
#!/bin/tcsh -f
if (! -d armv7) mkdir armv7
if (! -d lib) mkdir lib
rm armv7/*.a
make clean
./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' --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/
rm lib/*.a
cp armv7/*.a lib/
I have also tried to switch to the gcc-4.2 as well as the llvm-gcc-4.2. However I get an "Unknown option" error shown below in the comments.
Any info will be great and thanks.
UPDATED: Completely changed the answer to use the script that I use.
You will also need to download gas-preprocessor.pl from https://github.com/yuvi/gas-preprocessor, put it in your path and make it executable.
Then create a script (say make_for_iphone.sh) and put this in it:
export PLATFORM="iPhoneOS"
export MIN_VERSION="4.0"
export MAX_VERSION="5.0"
export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=$DEVROOT/SDKs/${PLATFORM}${MAX_VERSION}.sdk
export CC=$DEVROOT/usr/bin/llvm-gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/llvm-g++
export AR=$DEVROOT/usr/bin/ar
export LIBTOOL=$DEVROOT/usr/bin/libtool
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
COMMONFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -isysroot ${SDKROOT} -marm -fPIC"
export LDFLAGS="${COMMONFLAGS} -fPIC"
export CFLAGS="${COMMONFLAGS} -fvisibility=hidden"
export CXXFLAGS="${COMMONFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden"
FFMPEG_LIBS="libavcodec libavdevice libavformat libavutil libswscale"
echo "Building armv6..."
make clean
./configure \
--cpu=arm1176jzf-s \
--extra-cflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION} -mthumb' \
--extra-ldflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION}' \
--enable-cross-compile \
--arch=arm \
--target-os=darwin \
--cc=${CC} \
--sysroot=${SDKROOT} \
--prefix=installed \
--disable-network \
--disable-decoders \
--disable-muxers \
--disable-demuxers \
--disable-devices \
--disable-parsers \
--disable-encoders \
--disable-protocols \
--disable-filters \
--disable-bsfs \
--enable-decoder=h264 \
--enable-decoder=svq3 \
--enable-gpl \
--enable-pic \
--disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3
mkdir -p build.armv6
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv6/; done
echo "Building armv7..."
make clean
./configure \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION} -mthumb' \
--extra-ldflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION}' \
--enable-cross-compile \
--arch=arm \
--target-os=darwin \
--cc=${CC} \
--sysroot=${SDKROOT} \
--prefix=installed \
--disable-network \
--disable-decoders \
--disable-muxers \
--disable-demuxers \
--disable-devices \
--disable-parsers \
--disable-encoders \
--disable-protocols \
--disable-filters \
--disable-bsfs \
--enable-decoder=h264 \
--enable-decoder=svq3 \
--enable-gpl \
--enable-pic \
--disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3
mkdir -p build.armv7
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv7/; done
mkdir -p build.universal
for i in ${FFMPEG_LIBS}; do lipo -create ./build.armv7/$i.a ./build.armv6/$i.a -output ./build.universal/$i.a; done
for i in ${FFMPEG_LIBS}; do cp ./build.universal/$i.a ./$i/$i.a; done
make install
This compiles both armv6 and armv7 versions and puts them into a fat library using lipo. It installs to a folder underneath where you run the script from called installed.
Note that at the moment I've had to turn off inline assembly using a perl inline replace to change HAVE_INLINE_ASM from 1 to 0. This is because of this problem with gas-preprocessor.pl - https://github.com/yuvi/gas-preprocessor/issues/16.
Also note that this has turned off all encoders, decoders, muxers, demuxers, etc except for the H264 decoder. Just change the configure lines to compile what you want for your use case.
Please remember also that this has enabled GPL code - so you should be aware about what that means for iPhone apps. If you're not aware then you should do some reading about that.
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
I've created an "ffmpeg4ios" project at https://github.com/ciphor/ffmpeg4ios, which is successfully compiled on iOS 5.0.
You can check it.