I am trying to build ffmpeg on iOS5.1 (armv7), when I try to run ./configure like this:
./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
I get the following error:
/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.
Could somebody please provide the correct parameters in iOS5.1?
Thanks in advance
the instructions have changed since there is no longer a gcc in the xcode SDK.
What you need to do is specify that cc is the iphoneos compiler using xcrun, so where we previously just put the path to gcc, we're now going to put a reference to xcrun for clang.
I downloaded the latest ffmpeg from git, made sure I had a copy of gas-preprocess.pl on the path, and then changed the --cc= line to read:
--cc='xcrun -sdk iphoneos clang -mios-version-min=5.1'
(this assumes you're building and still targetting ios 5.1 - if you're targetting newer, then you change the value to the newer release. I specified 7.0 for mine, but I'm also using the iOS 8.4 SDK, so the configure line looks like:
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver \
--enable-cross-compile --arch=arm --target-os=darwin \
--cc='xcrun -sdk iphoneos clang -mios-version-min=7.0' \
--sysroot=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk \
--cpu=cortex-a8 --extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7 -isysroot /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk' \
--enable-pic
which builds ffmpeg from the ios8.4 SDK. These instructions should keep working; you just need to replace the appropriate 7.0/8.4 values for the newer SDKs.
OLD ANSWER
That's what happens when you try to compile iOS code using the MacOS version of the compiler.
You need to specify the iPhoneOS version of gcc using:
./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/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
The first step when trying to debug problems with configure is to look at the config.log file which is generated as part of the run.
There is a few things wrong with your configure script, that I can tell. First of all, you are using:
--cc=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
This is wrong. You should be using the architecture specific gcc compilers, so in your case (armv7) you should be using, for example:
--cc=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1
Notice you're calling upon the arm-apple-darwin10-gcc-4.2.1 version of apple's own gcc.
Since this is only an example, look in your ../Developer/../bin/ and use the latest arm-apple-darwin10-gcc-x.x.x that you have. I see that there are a lot of answers on SO that suggest you do it the way you have done it, this is just flat out wrong! and doesn't work for arm, it'll work for i386 (simulator) only.
You will need to update the assembler directive to reflect using the same gcc version:
--as='gas-preprocessor/gas-preprocessor.pl /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1'
Additionally, don't put an -arch armv7 in your --extra-cflags, you may get an
error: unrecognized command line option "-arch"
Lastly and depending on your situation, might I suggest the following, in addition to what you already have:
--disable-bzlib --disable-gpl --disable-shared --enable-static --disable-mmx --disable-debug --disable-neon
and change to this:
--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'
Hope this helps.
Related
How do I collect on ios ffmpeg with support for floating-point ABI?
I have an application that shows the video, but slow decoding.
ffmpeg compiled without support for floating-point ABI
./configure --prefix=armv7 --disable-ffmpeg --disable-ffplay --disable-ffprobe
--disable-ffserver --enable-avresample --enable-cross-compile
--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
--target-os=darwin
--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"
--extra-cflags="-arch armv7 -mfpu=neon -mfloat-abi=hard
-miphoneos-version-min=6.1" --extra-ldflags="-arch armv7
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -miphoneos-version-min=1.0"
--arch=arm --cpu=cortex-a9 --enable-pic
I always get a warning
WARNING: Compiler does not indicate floating-point ABI, guessing soft.
I have tried
-mfloat-abi=hard
This may be a toolchain problem: which compiler is it using, gcc or clang? (Clang seems not to support the float-abi flag: http://www.google.com/search?q=clang+float-abi is full of woeful tales.)
See this page for info about LGPL and iOS incompatibility, you need to think about this before attempting to use ffmpeg in an iOS app: compatibility-between-the-iphone-app-store-and-the-lgpl. There are other options that are fully legal, and if you are doing h.264 encoding just using the built-in hardware is way way faster anyway.
I've been trying to compile the ffmpeg libraries for IOS. I can get it to work if I use --disable-asm, but for performance I'd like to build with them enabled.
This is one of many configure commands I've used.
./configure --prefix=armv7 --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc" --extra-cflags="-arch armv7 -miphoneos-version-min=5.0" --extra-ldflags="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -miphoneos-version-min=6.0" --arch=arm --cpu=cortex-a9 --disable-everything --enable-pic --enable-static --disable-shared
It compiles fine, but when I try to link against it in my project I get :
ld: in /ffmpeg/libavcodec/libavcodec.a(simple_idct_armv5te.o), in section _TEXT,_text reloc 0: R_ABS reloc but no absolute symbol at target address for architecture armv7
Am I missing some key option? I've tried using the 1.0 build and the latest git version of ffmpeg.
I ran into the same problem. The solution for me was to switch to the newer gas-preprocessor.pl which can be found here: https://github.com/mansr/gas-preprocessor
Just install this in place of the old one you're currently using.
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.
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
Can any One Tell me how do i integrate FFMPEG in my iphone/ ipad project.i m using Xcode 4.
i searched a lot but did not find any useful Link .please tell me step by step procedure to integrate FFMpeg in my project.
thanks,
Prerequisites
MacPorts to install:open terminal and type
sudo port install pkgconfig
Launch Terminal and download FFmpeg source
The location of the directory is up to your personal preference and I chose to save it in a ffmpeg folder under my Home folder for easy access later on.
git clone git://source.ffmpeg.org/ffmpeg.git ~/ffmpeg
Before we go further, we need to think ahead and realize that we are likely to do some simulation on Mac itself along with actual testing on iPhone. What we need to do is that we need to build libraries for 3 architectures: armv7 (iPhone 3Gs or later), armv7s (iPhone 5) and i386 (iPhone Simulator).
Let’s create some folders inside ffmpeg folder to hold 3 different builds so that we can lipo those together into one universal build.
cd ffmpeg
mkdir armv7
mkdir armv7s
mkdir i386
mkdir -p universal/lib
To Install gas-preprocessor
Click on the ZIP icon to download gas-preprocessor.
Copy gas-preprocessor.pl to /usr/bin directory.
Change permission of gas-preprocessor.pl by setting the privilege to Read & Write for all.
Configure FFmpeg for armv7 build
Before configuring,
You may refer to the detailed options by going in to the ffmpeg folder and type:
./configure --help
list of options for your reference: FFmpeg Configure Options. The “Components options” will be up to you depending on what you want to do with FFmpeg.
Now run the following configure options:
./configure \
--prefix=armv7 \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-avresample \
--enable-cross-compile \
--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk"
\
--target-os=darwin \
--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"
\
--extra-cflags="-arch armv7 -mfpu=neon -miphoneos-version-min=6.0" \
--extra-ldflags="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
-miphoneos-version-min=6.0" \
--arch=arm \
--cpu=cortex-a9 \
--enable-pic \
You may get a warning such as:
WARNING: Compiler does not indicate floating-point ABI, guessing soft.
No worries. You should be fine to continue to next steps.
Build FFmpeg for armv7
Run the build commands:
make clean && make && make install
Now you should be able to see files are populated inside the ffmpeg/armv7 folder. We now move onto building for armv7s for iPhone 5.
Configure and Install FFmpeg for armv7s architecture (iPhone 5)
.
/configure \
--prefix=armv7s \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-avresample \
--enable-cross-compile \
--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk"
\
--target-os=darwin \
--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"
\
--extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=6.0" \
--extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
-miphoneos-version-min=6.0" \
--arch=arm \
--cpu=cortex-a9 \
--enable-pic \
Then build with:
make clean && make && make install
Configure FFmpeg for i386 build
./configure \
--prefix=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/iPhoneSimulator6.0.sdk"
\
--target-os=darwin \
--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc"
\
--extra-cflags="-arch i386" \
--extra-ldflags="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk"
\
--arch=i386 \
--cpu=i386 \
--enable-pic \
--disable-asm \
Please note the last --disable-asm tag. If you forget to include this tag, you will likely to receive this error:
cc1: error in backend: Ran out of registers during register
allocation! make: *** [libavcodec/h264_cabac.o] Error 1
Build FFmpeg for i386
make clean && make && make install
Create universal library
The lipo commands (assuming you are still under the ffmpeg folder):
(Please note that Mountain Lion-supplied lipo knows nothing about armv7s as of yet. So we need to use xcrun to find the lipo supplied with the SDK.)
cd armv7/lib for file in *.a do cd ../.. xcrun -sdk iphoneos lipo
-output universal/lib/$file -create \
-arch armv7 armv7/lib/$file \
-arch armv7s armv7s/lib/$file \
-arch i386 i386/lib/$file echo "Universal $file created." cd - done cd ../..
Look under universal/lib, you will find all FAT libs freshly baked there. We now turn our attention to linking these static libraries to the Xcode project.
if you are getting error like this Error: No developer directory found at /Developer”? then type
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Linking static libraries in Xcode
Firstly, we pull in the .a files.
Create a new Empty Application using Xcode. Assign a Product Name and Company Identifier. Then click Next and save the project.
Locate the universal libs that we created (the .a files) under ffmpeg/universal/lib.
Drag the .a files into the Frameworks folder in the Project Navigator pane.
Tick “Copy items into destination group’s folder (if needed)”. And click Finish.
Now we take care of the include files.
Locate the include files under ffmpeg/armv7/include.
Drag and drop the content of that folder onto the Project Name folder in the Project Navigator pane.
Again, tick “Copy items into destination group’s folder (if needed)”. Then click Finish.
Finally, we need to set the Header Search Paths for the project.
Click on the Project in the Project Navigator pane.
In the Standard Editor in the middle of the screen, click on Build Settings.
Search for “Header Search Paths”.
Add your project path and set it to Recursive. i.e. $(SRCROOT)
Click on Build Phases.
Under Link Binary With Libraries, add libbz2.dylib and libz.dylib.
Test and verify the working of library
We are not going to be in-depth here. Just to verify that the library is functioning.
Go to your AppDelegate.m, and add:
> #include "avformat.h"
And in the didFinishLaunchingWithOptions function, add:
av_register_all();
if suppose you are getting this errors means
Undefined symbols for architecture i386:
"_iconv", referenced from:
_mail_iconv in libmailcore.a(charconv.o)
"_iconv_open", referenced from:
_charconv in libmailcore.a(charconv.o)
_charconv_buffer in libmailcore.a(charconv.o)
"_iconv_close", referenced from:
_charconv in libmailcore.a(charconv.o)
_charconv_buffer in libmailcore.a(charconv.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
then add libiconv.dylib framework
you are now ready to dive in to develop using FFmpeg on iOS.
./configure script:
./configure --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 --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/iPhoneOS4.3.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7' --enable-pic
this works fine. since the default FFMPEG configuration script has the default Library path set to /usr/lib/system so it can not find library libcache.dylib, so here I have set it to the latest sdk path.
Like many others.. I'm compiling ffmpeg using gas preprocessor
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-October/077701.html
This is my command
./configure --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 --as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk --enable-cross-compile --target-os=darwin --arch=arm7 --cpu=cortex-a8 --enable-pic
the error:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 is unable to create an executable file.
C compiler test failed.
I looked up the /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ folder using Finder..
arm-apple-darwin10-gcc-4.2.1 was there..
Thanks,
Suhas
Guess; Try switching the compiler to llvm (but not gas).