FFMPEG iOS 7 Library - ios

I've tried reading many tutorials.
I've spent hours on google, and stackoverflow trying answer.
So far I've read: Trying to compile the FFMPEG libraries for iPhoneOS platform with armv6 and arv7 architecture FFMPEG integration on iphone/ ipad project and https://github.com/lajos/iFrameExtractor few of the many.
I'm trying to build this library for iOS 7/Xcode 5 compatibility but it's not working.
A common error I'd get is:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
yasm/nasm not found or too old. Use --disable-yasm for a crippled build.
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user#ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
I'd also get many more once that is finished. Such as:
rm: illegal option -- .
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
make: *** [clean] Error 64
I've mostly tried using this command to start, but it always crashes on "make clean":
./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='/usr/local/bin/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/iPhoneOS7.0.sdk \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk' \
--prefix=compiled/armv7 \
--enable-cross-compile \
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug

To use the mooncatventures (our) ffmpegdecoderFramework, go into build settings
click on the arch and remove the armv7s.
you must also change build active architechure only to no.

This answer from mientus worked for me :
https://stackoverflow.com/a/19370679/661720
Support universal ffmpeg library for iOS7 and XCode5:
Install gas-preprocessor
Click on the ZIP icon to download
https://github.com/mansr/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.
Download my shell script from: https://gist.github.com/m1entus/6983547
Run sh build-ffmpeg.sh.

Related

Building and linking lua from source via makefile

I've tried to compile and link lua with my application. This is my makefile:
app.o: app.cpp
g++ -c app.cpp
PATH_LUA=../lua-5.4.3/src
LUA= \
$(PATH_LUA)/lapi.c \
$(PATH_LUA)/lauxlib.c \
$(PATH_LUA)/lbaselib.c \
$(PATH_LUA)/lcode.c \
$(PATH_LUA)/lcorolib.c \
$(PATH_LUA)/lctype.c \
$(PATH_LUA)/ldblib.c \
$(PATH_LUA)/ldebug.c \
$(PATH_LUA)/ldo.c \
$(PATH_LUA)/ldump.c \
$(PATH_LUA)/lfunc.c \
$(PATH_LUA)/lgc.c \
$(PATH_LUA)/linit.c \
$(PATH_LUA)/liolib.c \
$(PATH_LUA)/llex.c \
$(PATH_LUA)/lmathlib.c \
$(PATH_LUA)/lmem.c \
$(PATH_LUA)/loadlib.c \
$(PATH_LUA)/lobject.c \
$(PATH_LUA)/lopcodes.c \
$(PATH_LUA)/loslib.c \
$(PATH_LUA)/lparser.c \
$(PATH_LUA)/lstate.c \
$(PATH_LUA)/lstring.c \
$(PATH_LUA)/lstrlib.c \
$(PATH_LUA)/ltable.c \
$(PATH_LUA)/ltablib.c \
$(PATH_LUA)/ltm.c \
$(PATH_LUA)/lundump.c \
$(PATH_LUA)/lutf8lib.c \
$(PATH_LUA)/lvm.c \
$(PATH_LUA)/lzio.c
libLua.so:
g++ -shared $(LUA) -fPIC -o lua/libLua.so
all: libLua.so app.o
g++ -o app app.o -I$(PATH_LUA) -lLua -Llua -ldl
The compilation works fine, but something is wrong with the linkage, because I get tons of undefined references to "lua_XYZ-function". The undefined reference to lua_tointegerx for example makes no sense, since its implementation is located in lapi.c which is in the file-list above.
(INB4: "This is a duplicate question!" … I've tried my best to check them all.)
What am I missing?
You are putting the libLua.so (by the way, personally I think it's a really bad idea to name your library the same name as the standard library, just uppercase... there's no way that can't bite you or someone in the rear at some point) in the lua subdirectory but you don't tell the linker where to find it.
Then, you list liblua.a as the prerequisite, but you have no actual rule to build liblua.a, which means make will come up with one based on its internal rules... whatever rule it uses will certainly not include all your source files (how could it know?).
If you show us the actual output of running make (before all the error messages) it should be pretty clear this has gone wrong from the beginning.
Speaking from a strictly makefile perspective, it's virtually always wrong to have the name of the file your recipe builds be different than the name of the target in the makefile.
You have to compile lua as c++-code explicitly.
You do this by including
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
instead of
#include <lua.hpp> which includes that extern "C" {...} statement.

How to cross-compile Coreutils or other GNU projects with clang/LLVM?

I have a tough need to compile Coreutils with llvm for other arch: arm/aarch64/mips/mips32/ppc/ppc32...
Since I install all the gcc-cross tools like mips-linux-gnu, powerpc64-linux-gnu and if I have a simple C program like that test.c
#include<stdio.h>
int main(){
printf("hello!");
return 0;
}
I can compile it to the arch, i.e.
clang --target=mips64-linux-gnuabi64 test.c -o test-mips64
➜ tests file test-mips64
test-mips64: ELF 64-bit MSB executable, MIPS, MIPS64 rel2 version 1 (SYSV), dynamically linked, interpreter /lib64/ld.so.1, BuildID[sha1]=7b33d55a0d08e6cd18d966341590dc351e346a78, for GNU/Linux 3.2.0, not stripped
I try to the same way for compile Coreutils that try to set
export CC=clang
export CXX=clang++
CFLAGS = "--target=mips64-linux-gnuabi64"
./configure --host=mips64-linux-gnuabi64
Howerver, every time got errors in configure or make...
How should I set the configure? Can I easily compile Coreuntils with llvm for other archs?
It's a bit tricky to get the command-line options right for cross-compiling. I got it to work with the commands below, assuming you're working on a Debian-based system (like Debian or Ubuntu). Here are the steps.
Install gcc-mips64-linux-gnuabi64 and gcc-powerpc64-linux-gnu.
Choose the correct arguments for CFLAGS
-B/usr/mips64-linux-gnuabi64/bin/ to indicate we want to use the linker ld within that directory. Do the same for powerpc.
--target=mips64-linux-gnuabi64 to indicate what our target for compilation is. Do the same for powerpc.
-I/usr/mips64-linux-gnuabi64/include to include header files. Do the same for powerpc.
Use ./configure --host=mips64-linux-gnuabi to configure for mips64 and ./configure --host=powerpc64-linux-gnueabi to configure for powerpc64.
Here are the commands to compile for mips64:
make clean
CFLAGS="-B/usr/mips64-linux-gnuabi64/bin/ --target=mips64-linux-gnuabi64 -I/usr/mips64-linux-gnuabi64/include" \
./configure --host=mips64-linux-gnuabi
make
And the commands to compile for powerpc64:
make clean
CFLAGS="-B/usr/powerpc64-linux-gnu/bin/ --target=powerpc64-linux-gnueabi -I/usr/powerpc64-linux-gnu/include" \
./configure --host=powerpc64-linux-gnueabi
make
Here is the output of file ./src/ls to demonstrate that it is a powerpc64 executable:
$ file ./src/ls
./src/ls: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked, interpreter /lib64/ld64.so.1, for GNU/Linux 3.2.0, BuildID[sha1]=97fe33981ca0112160f44a6fb678d6dc1b462114, not stripped
Below is a Dockerfile that can be used to reproducibly cross-compile coreutils for mips64 and powerpc64.
# Cross-compile GNU coreutils for mips64 and powerpc64 using clang.
# With help from https://medium.com/#wolfv/cross-compiling-arm-on-travis-using-clang-and-qemu-2b9702d7c6f3
FROM debian:buster
# Install compile-time dependencies.
RUN apt-get update \
&& apt-get install --yes \
clang \
curl \
gcc-mips64-linux-gnuabi64 \
gcc-powerpc64-linux-gnu \
make \
perl \
&& rm -rf /var/lib/apt/lists/*
# Download source code for release.
WORKDIR /tmp/coreutils
RUN curl -fsSL https://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz \
| tar xJ --strip-components 1
# Compile and install for mips64.
RUN CFLAGS="-B/usr/mips64-linux-gnuabi64/bin/ --target=mips64-linux-gnuabi64 -I/usr/mips64-linux-gnuabi64/include" \
./configure --host=mips64-linux-gnuabi --prefix=/opt/coreutils-mips \
&& make \
&& make install
# Compile and install for powerpc64.
RUN make clean \
&& CFLAGS="-B/usr/powerpc64-linux-gnu/bin/ --target=powerpc64-linux-gnueabi -I/usr/powerpc64-linux-gnu/include" \
./configure --host=powerpc64-linux-gnueabi --prefix=/opt/coreutils-powerpc64 \
&& make \
&& make install
# Keep only the compiled programs from the previous stage.
FROM debian:buster
COPY --from=0 /opt /opt
I am current working on a simple build tool in Python that maybe help you.
Unfortunately, still at moment, lacks clang implementation, but works fine with GCC and MSVC.
Basically the thing mix Json parameters files to generate command line building.
CppMagic

Cross-compiling on Linux for iOS

I am trying to cross-compile Ruby for iOS devices. I have a rather lengthy script that downloads the latest source code for Ruby, unzips it, and compiles it.
The script is as follows:
#!/bin/bash
rm -rf ~/built/ruby
AR=~/toolchain/armv7-apple-darwin11-ar
AS=~/toolchain/armv7-apple-darwin11-as
CC=~/toolchain/armv7-apple-darwin11-clang
CXX=~/toolchain/armv7-apple-darwin11-clang++
LD=~/toolchain/armv7-apple-darwin11-ld
NM=~/toolchain/armv7-apple-darwin11-nm
OBJDUMP=~/toolchain/armv7-apple-darwin11-objdump
RANLIB=~/toolchain/armv7-apple-darwin11-ranlib
STRIP=~/toolchain/armv7-apple-darwin11-strip
SDK=/home/citrusui/sdks/iPhoneOS9.3.sdk
CFLAGS="-arch armv7 -arch arm64 -isysroot $SDK"
LDFLAGS="-Wl,-segalign,4000"
DESTDIR=~/built/ruby/var/stash
apt install autoconf bison clang jq xutils-dev
curl https://api.github.com/repos/ruby/ruby/tags -o ruby.json
URL=`jq -r 'map(select(.name != "yarv_migration_base"))[0].tarball_url' ruby.json`
TAG=`jq -r 'map(select(.name != "yarv_migration_base"))[0].name' ruby.json`
echo "Downloading from $URL"...
if [ -f ruby_$TAG.tar.gz ] && [ -d ruby-ruby* ]; then
echo "Already downloaded."
cd ruby-ruby*
autoconf
./configure --host=armv7-apple-darwin11 -target=armv7-apple-darwin11 CC="$CC" CXX="$CXX" CXXFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STRIP=$STRIP RANLIB=$RANLIB NM=$NM AR=$AR AS=$AS LD=$LD OBJDUMP=$OBJDUMP LDFLAGS="$LDFLAGS" DESTDIR="$DESTDIR"
make install -j4
cd ~/built/ruby
lndir var/stash
exit 0
fi
curl -L $URL -o ruby_$TAG.tar.gz
tar -xvzf ruby_$TAG.tar.gz
cd ruby-ruby*
autoconf
./configure --host=armv7-apple-darwin11 -target=armv7-apple-darwin11 CC="$CC" CXX="$CXX" CXXFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STRIP=$STRIP RANLIB=$RANLIB NM=$NM AR=$AR AS=$AS LD=$LD OBJDUMP=$OBJDUMP LDFLAGS="$LDFLAGS" DESTDIR="$DESTDIR"
make install -j4
cd ~/built/ruby
lndir var/stash
Now, I have also downloaded the iOS 9.3 SDK from Xcode and dropped it into my ~/sdks/ folder. However, the compiling process still results in ELF format binaries.
I also have a toolchain (in ~/toolchain/) downloaded from here. I assume this will allow LLVM/Clang to produce arm(64) binaries, but I don't know how I would tell clang to process this toolchain. Specifying $TOOLCHAIN in ./configure doesn't help, either.

FFMpeg for IOS - Disabling Log Levels

I have compiled ffmpeg for ios. The configuration for compiling, i have borrowed from kxmovie's Rake file.
Everything works fine, but i would like to disable all the debug messages showed in console by the decoder.
How can i achieve this. I believe it should be the ffmpeg is compiled, but am not sure how to go about it. Any suggestions would be highly appreciated.
configure command:
./configure --disable-ffmpeg --disable-ffplay --disable-ffserver
--disable-ffprobe --disable-doc --disable-bzlib --target-os=darwin --enable-cross-compile --enable-gpl --enable-version3 --assert-level=2 --disable-mmx --arch=i386 --cpu=i386 --extra-ldflags='-arch i386' --extra-cflags='-arch i386' --disable-asm --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc
--as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc'
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk
--extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/usr/lib/system
Can you just set -loglevel to quiet? I'm not sure there is a compile option and even if there is, it will make debugging harder since you'll need a different ffmpeg binary for debugging.

Cross compiling fontconfig for iOS

How to cross compiling for fontconfig for iOS.
http://freedesktop.org/software/fontconfig/release
I try this:
./configure
CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -arch armv7"
--sysconfdir=/Users/bluefish625/Desktop/fontconfig/sysconfdir/
--prefix=/Users/bluefish625/Desktop/fontconfig/prefix/
--mandir=/Users/bluefish625/Desktop/fontconfig/mandir
--disable-shared
--host=armv7-apple-darwin
--with-freetype-config=$PREFIX/bin/freetype-config
The error info is:
configure: error: in `/Users/bluefish625/Downloads/fontconfig-2.9.0':
configure: error: The pkg-config script could not be found or is too old.
Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config.
Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details
And,I don't know what this --with-freetype-config means?
can somebody help me? thanks.
Try with this:
export IOS_PLATFORMDIR="/Developer/Platforms/iPhoneOS.platform"
export IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS5.0.sdk"
export IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
export IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
./configure --host arm-apple-darwin10 --disable-docs --enable-shared=no \
--with-expat="/Users/meox/PODOFO/expat" \
--with-expat-includes="/Users/meox/PODOFO/expat/include" \
--with-expat-lib="/Users/meox/PODOFO/expat" \
CC="$IOS_GCC" LD="$IOS_GCC" \
CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS
-L/Users/meox/PODOFO/freetype2 -L/Users/meox/PODOFO/expat
-L/Users/meox/PODOFO/zlib -L/Users/meox/PODOFO/libiconv
-L/Users/meox/PODOFO/bzip2" \
CPPFLAGS="-I/Users/meox/PODOFO/freetype2/include
-I/Users/meox/PODOFO/zlib/include -I/Users/meox/PODOFO/expat/include"
You have to set the right paths.

Resources