[Libav-user] Trying to compile ffmpeg for iOS

Alex Cohn alexcohn at netvision.net.il
Tue Mar 27 19:05:01 CEST 2012


On Tue, Mar 27, 2012 at 18:00, Wagner Patriota
<wagner.patriota at gmail.com> wrote:
> Thanks Gavin,
>
> I am using the latest SDK and the latest FFMPEG..
>
> I tried this:
> ./configure
> --enable-static
> --disable-shared
> --enable-pic
> --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk"
> --extra-ldflags="-arch armv7 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
> -miphoneos-version-min=5.1"
> --enable-cross-compile
> --arch=arm
> --target-os=darwin
> --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"
> --cpu=cortex-a8
> --extra-cflags="-arch armv7 -mfpu=neon -miphoneos-version-min=5.1"
> --disable-debug
> --enable-small
> --disable-asm
>
> based on your command, with some modifications in BOLD....
>
> well.. it compiles... but when I try to link with my application I have:
>
> Undefined symbols for architecture armv7:
>
>   "__Z13avcodec_open2P14AVCodecContextP7AVCodecPP12AVDictionary", referenced
> from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z21avformat_write_headerP15AVFormatContextPP12AVDictionary", referenced
> from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z26av_interleaved_write_frameP15AVFormatContextP8AVPacket", referenced
> from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z7av_freePv", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z10avio_flushP11AVIOContext", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z15av_guess_formatPKcS0_S0_", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z13av_dup_packetP8AVPacket", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z15av_register_allv", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z14av_dump_formatP15AVFormatContextiPKci", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z14av_free_packetP8AVPacket", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z20avcodec_find_decoder7CodecID", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z10avio_closeP11AVIOContext", referenced from:
>
>       __Z4doItv in Smooth.o
>
>
> "__Z19avformat_open_inputPP15AVFormatContextPKcP13AVInputFormatPP12AVDictionary",
> referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z16av_write_trailerP15AVFormatContext", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z9avio_openPP11AVIOContextPKci", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z13avcodec_closeP14AVCodecContext", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z19avformat_new_streamP15AVFormatContextP7AVCodec", referenced from:
>
>       __ZL17add_output_streamP15AVFormatContextP8AVStream in Smooth.o
>
>   "__Z25avformat_find_stream_infoP15AVFormatContextPP12AVDictionary",
> referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z8av_freepPv", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z22avformat_alloc_contextv", referenced from:
>
>       __Z4doItv in Smooth.o
>
>   "__Z13av_read_frameP15AVFormatContextP8AVPacket", referenced from:
>
>       __Z4doItv in Smooth.o
>
> ld: symbol(s) not found for architecture armv7
>
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
>
> Any suggestion?
>
> Thanks...
>
>
>
>
> On Tue, Mar 27, 2012 at 9:23 AM, Gavin Kinsey <gkinsey at ad-holdings.co.uk>
> wrote:
>>
>> On Friday 23 March 2012 21:22:33 Wagner Patriota wrote:
>> > Has anybody done it yet?
>>
>> Yes, haven't tested with the latest SDK yet but for 5.0 and below I have
>> it
>> working.
>>
>> > I am using the following commands:
>> >
>> <snip commands>
>> >
>> > But when I try to link my application with the libraries this above
>> > script generates, I get the following:
>> >
>> > "ld: warning: ignoring file
>> > /Users/Wagner/ffmpeg/ffmpeg/armv7/libavcodec.a, file was built for
>> > archive which is not the architecture being linked (armv7)"
>>
>> Configure flags that I use (minus the disable/enable decoders and stuff I
>> have
>> which aren't relevant)
>>
>> configure --enable-static --disable-shared --enable-pic --
>>
>> sysroot="/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"
>> --extra-ldflags="-arch armv7 -isysroot
>> /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -
>> miphoneos-version-min=4.0" --enable-cross-compile --arch=arm --target-
>> os=darwin --
>> cc="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" --
>> cpu=cortex-a8 --extra-cflags="-arch armv7 -mfpu=neon -miphoneos-version-
>> min=4.0" --disable-debug --enable-small
>>
>> I also have a small patch to work around Apple gcc brokenness, which I've
>> attached.
>>
>> --
>> Gavin Kinsey
>> AD Holdings Plc

In your Smooth.cpp you should wrap #include "avformat.h" in extern "C"
{ ... }, same for other ffmpeg include files.

Hope this helps,
Alex Cohn


More information about the Libav-user mailing list