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.
Related
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
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.
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).
I have a Library built in Macosx ibopencore-amrnb.a. Can I use it with my Iphone app as library? If yes How ? If not How Do i get the library working with Iphone app?
Thanks,
Sowri
Mac osX is an X86 platform the iphone uses an ARM processor so at the very least it needs to be recompiled.The architectures are very different ,though, so things like endeaness(?) and word size must be taken into consideration.
Step 1) Build the static libraries.
I've built third-party libraries, statically, for the iPhone. After a bit of trial-and-error, here's what I found to be a good starting point:
Cross-Compile for iPhoneOS:
./configure --prefix=/path/to/project/external/iphoneos/ --host="arm-apple-darwin9" --target=arm-apple-darwin9 --enable-static --disable-shared CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
make
make install
Cross-Compile for iPhoneSimulator:
./configure --prefix=/path/to/project/external/iphonesimulator --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 CFLAGS="-arch i686 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -mmacosx-version-min=10.5 -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/include/ -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk" CPP=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar LDFLAGS="-arch i686 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -Wl,-dead_strip -mmacosx-version-min=10.5"
make
make install
However, it's really just a starting point. It'll probably only work for projects with flexible Makefiles. If the above doesn't work, I've had to:
turn on project-specific ./configure flags
modify the configure script
modify the generated Makefile
modify autoconfigure scripts
You can also turn on optimization flags for the iPhoneOS version (after you've got it working first).
Step 2) Add the libraries to your project's search path.
In your projects Info settings, set these Build options:
Header Search Paths: "$(SRCROOT)/external/$(PLATFORM_NAME)/include"
Library Search Paths: "$(SRCROOT)/external/$(PLATFORM_NAME)/lib"
Other Linker Flags: [Add the flags for your static libs]
Afterwards, you should be able to include the third-party libraries in your project.