I'm running this script as an Xcode run script to build graphviz:
if [ ! "${BUILT_PRODUCTS_DIR}/graphviz/Makefile" -nt "${SRCROOT}/graphviz/configure" ]
then
GVROOT="${SRCROOT}/graphviz"
# figure out optimization
OPT="${GCC_OPTIMIZATION_LEVEL}"
if [ -z "${OPT}" ]
then
OPT="s"
fi
FLAGS="-fexceptions -gdwarf-2 -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -mthumb -O${OPT}"
# figure out architecture
for ARCH in ${ARCHS}
do
FLAGS="${FLAGS} -arch ${ARCH}"
done
# figure out preprocessor defines
for DEFINITION in ${GCC_PREPROCESSOR_DEFINITIONS}
do
FLAGS="${FLAGS} -D${DEFINITION}"
done
mkdir -p ${BUILT_PRODUCTS_DIR}/graphviz
cd ${BUILT_PRODUCTSx_DIR}/graphviz
${GVROOT}/configure \
--build=${NATIVE_ARCH_ACTUAL}-apple-darwin11 \
--host=${NATIVE_ARCH}-apple-darwin11 \
--disable-dependency-tracking \
--enable-shared=no \
--enable-static=yes \
--enable-ltdl=no \
--enable-swig=no \
--enable-tcl=no \
--srcdir=${GVROOT} \
--with-codegens=no \
--with-graph=yes \
--with-expat=no \
--with-fontconfig=no \
--with-freetype2=no \
--with-ipsepcola=yes \
--with-libgd=no \
--with-quartz=yes \
--with-visio=yes \
--with-x=no \
CC="${PLATFORM_DEVELOPER_BIN_DIR}/clang" \
CPP="${PLATFORM_DEVELOPER_BIN_DIR}/clang -E" \
CXX="${PLATFORM_DEVELOPER_BIN_DIR}/clang++" \
OBJC="${PLATFORM_DEVELOPER_BIN_DIR}/clang" \
LD="${PLATFORM_DEVELOPER_BIN_DIR}/ld" \
CFLAGS="${FLAGS}" \
CXXFLAGS="${FLAGS} -fvisibility-inlines-hidden" \
OBJCFLAGS="${FLAGS}" 2>/dev/null
fi
I get the following compiler output:
checking build system type... x86_64-apple-darwin11
checking host system type... i386-apple-darwin11
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for i386-apple-darwin11-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /Users/michaelciccotti/Documents/Projects/Tests/LowGraphvix/graphviz/config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
Command /bin/sh failed with exit code 1
How do I figure out what is going wrong?
I figured out what was going wrong by running Xcode as root. This gave me more verbose failure messages (not sure why). My problem was that I needed to 'make distclean' because I had a previous build in the directory.
Related
I'm building "main.c" file:
int sum(int x, int y) {
return x + y;
}
int dbl(int x) {
return x + x;
}
void call_fn(int (*fn)(int)) {
(*fn)(42);
}
void erase_type(void *fn) {
call_fn(fn);
}
int main() {
erase_type(sum);
return 0;
}
for the host "x86" platform with enabled "cfi" sanitizer feature using following command:
./clang-8 \
-fsanitize=cfi \
-fvisibility=hidden \
-fno-sanitize-trap=all \
-fuse-ld=gold \
-flto \
main.c \
-o \
main
Now I need to compile this file for the "aarch64" processor.
I know how to simply compile this file (with disabled cfi feature).
rm -f main.o && \
./clang-8 \
-cc1 \
-triple \
aarch64-funnyos-unknown-gnueabi \
-emit-obj \
-target-cpu \
generic \
-O2 \
-Wall \
-o \
main.o \
-x \
c \
main.c \
&& \
file main.o
But I don't know how to compile "main.c" file for "aarch64" with "cfi" enabled.
Does anybody know how to do it?
UPD. Let suppose, that CPU is of ARMv8 type and Linux is running, for example, on QEMU emulator. Let suppose, host is x86 and run on Linux. I need to cross compile code on host x86 Linux for the ARMv8 target (which is run on QEMU, Linux).
Your x86 and AArch64 commands are very different. The first one runs compiler driver which supports compiler flags (-fsanitize=cfi in particular).
You second command though runs compiler proper (as indicated by -cc1 switch). This is an internal mode: it's run by compiler driver under the hood so it does not support normal compiler flags and is not meant to be run by ordinary users. You should switch to using compiler driver on AArch64.
At first, we need to compile main.c by clang's compiler into llvm's intermediate code:
./clang-8 \
--target=\
aarch64-funnyos-unknown-gnueabi \
-c \
-flto \
-fsanitize=cfi \
-fvisibility=default \
main.c \
-o \
main.o
Next step is to translate/link this code into binary file by means of gold linker (for example, from AndroidNDK) using gold plugin (from LLVM project), telling linker the emulation mode (-m option, which means for which architecture the binary should be generated):
/PATH/TO/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld.gold \
-pie \
-m \
aarch64_elf64_le_vec \
-o \
main \
-plugin \
/PATH/TO/llvm-project/build/lib/LLVMgold.so \
-plugin-opt=mcpu=generic \
-plugin-opt=O2 \
-plugin-opt=-debugger-tune=gdb \
main.o
P.S. Thanks to #yugr for assistance and help!
I compiled FFMPEG libs which supports for iOS 7 and 8 but since recent release with iOS 9 there is a new feature has issued which called bitcode mode , as a default setting , this setting has set to NO .
But if i set this as yes , following error will execute ,
libavdevice.a(avfoundation.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
Is there any way to compile FFMPEG which supports FFMpeg in bitcode enabled mode
here is the build script i used
#!/bin/sh
# directories
SOURCE="ffmpeg-2.6.2"
FAT="FFmpeg-iOS"
SCRATCH="scratch"
# must be an absolute path
THIN=`pwd`/"thin"
# absolute path to x264 library
#X264=`pwd`/fat-x264
#FDK_AAC=`pwd`/fdk-aac/fdk-aac-ios
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic"
if [ "$X264" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264"
fi
if [ "$FDK_AAC" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libfdk-aac"
fi
# avresample
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
ARCHS="arm64 armv7 x86_64 i386"
COMPILE="y"
LIPO="y"
DEPLOYMENT_TARGET="6.0"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
if [ ! `which yasm` ]
then
echo 'Yasm not found'
if [ ! `which brew` ]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" \
|| exit 1
fi
echo 'Trying to install Yasm...'
brew install yasm || exit 1
fi
if [ ! `which gas-preprocessor.pl` ]
then
echo 'gas-preprocessor.pl not found. Trying to install...'
(curl -L 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) \
|| exit 1
fi
if [ ! -r $SOURCE ]
then
echo 'FFmpeg source not found. Trying to download...'
curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
|| exit 1
fi
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"
if [ "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
if [ "$X264" ]
then
CFLAGS="$CFLAGS -I$X264/include"
LDFLAGS="$LDFLAGS -L$X264/lib"
fi
if [ "$FDK_AAC" ]
then
CFLAGS="$CFLAGS -I$FDK_AAC/include"
LDFLAGS="$LDFLAGS -L$FDK_AAC/lib"
fi
TMPDIR=${TMPDIR/%\/} $CWD/$SOURCE/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix="$THIN/$ARCH" \
|| exit 1
make -j3 install $EXPORT || exit 1
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
echo Done
I got it working using the following CONFIGURE_FLAGS:
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic \
--extra-cflags=-fembed-bitcode --extra-cxxflags=-fembed-bitcode"
If you only need to decode videos, you should add more flags to disable all muxers,encoders. You'll also probably don't need filters. This will save some space. I also disabled the ARCH i386, which is not needed for the iOS simulator.
I use these flags for my project:
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic \
--extra-cflags=-fembed-bitcode --extra-cxxflags=-fembed-bitcode \
--enable-nonfree --enable-gpl \
--disable-ffserver --disable-ffmpeg --disable-ffprobe \
--disable-avdevice --disable-avfilter --disable-encoders \
--disable-parsers --disable-decoders --disable-protocols \
--disable-filters --disable-muxers --disable-bsfs \
--disable-indevs --disable-outdevs --disable-demuxers \
--enable-protocol=file \
--enable-protocol=tcp \
--enable-protocol=udp \
--enable-decoder=msmpeg4v3 \
--enable-decoder=mpeg4 \
--enable-decoder=mjpeg \
--enable-decoder=h264 \
--enable-parser=mpeg4video \
--enable-parser=mjpeg \
--enable-parser=h263 \
--enable-parser=h264 \
--enable-parser=aac \
--enable-demuxer=aviĀ \
--enable-demuxer=mov \
--enable-demuxer=rtsp \
"
Add -fembed-bitcode-marker to CONFIGURE_FLAGS
like this:
CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \
--disable-doc --enable-pic -fembed-bitcode-marker"
I compile ffmpeg in OSX. My xcode version is 5.1. ffmpeg configure is :
./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/iPhoneOS7.1.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk' --enable-pic --disable-asm --prefix="../lib"
This is the error:
/usr/bin/ranlib: object: libavfilter/libavfilter.a(aeval.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make: *** [libavfilter/libavfilter.a] Error 1
I'm not sure what this error means or how to solve it.
I see you are trying to build it for ARM, therefore iOS...
It's not that simple... run this script here... if you uncomment X264 you can compile it with libx264, if you need that, I can send you the other script later.
#!/bin/sh
# directories
SOURCE="ffmpeg-2.3"
FAT=`pwd`/"fat"
SCRATCH="scratch"
# must be an absolute path
THIN=`pwd`/"thin"
# absolute path to x264 library
#X264=`pwd`/../x264/fat
CONFIGURE_FLAGS="--enable-cross-compile \
--disable-debug \
--disable-programs \
--disable-doc \
--enable-pic \
--enable-cross-compile \
--target-os=darwin \
--enable-nonfree \
--enable-gpl \
--enable-static \
--disable-shared \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm"
if [ "$X264" ]
then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-gpl --enable-libx264"
fi
# avresample
#CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"
ARCHS="arm64 armv7s armv7 x86_64 i386"
COMPILE="y"
LIPO="y"
DEPLOYMENT_TARGET="6.0"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
if [ ! `which yasm` ]
then
echo 'Yasm not found'
if [ ! `which brew` ]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" \
|| exit 1
fi
echo 'Trying to install Yasm...'
brew install yasm || exit 1
fi
if [ ! `which gas-preprocessor.pl` ]
then
echo 'gas-preprocessor.pl not found. Trying to install...'
(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) \
|| exit 1
fi
if [ ! -r $SOURCE ]
then
echo 'FFmpeg source not found. Trying to download...'
curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \
|| exit 1
fi
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"
if [ "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
if [ "$X264" ]
then
CFLAGS="$CFLAGS -I$X264/include"
LDFLAGS="$LDFLAGS -L$X264/lib"
fi
$CWD/$SOURCE/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix="$THIN/$ARCH" \
|| exit 1
make -j3 install $EXPORT || exit 1
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
echo Done
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.
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.