[Libav-user] Building with MSVC toolchain resulting in seeking problem?

John Orr john.orr at scala.com
Tue Mar 12 16:18:52 CET 2013


On 3/12/2013 6:52 AM, Bjoern Drabeck wrote:
>
>     > I have got that to build, however compared to builds
>     > from the zeranoe site (and also builds I have asked a
>     > friend of mine to make for me using mingw with gcc),
>     > I always end up with seeking problems.
>
>     This is surprising.
>     Are you sure that you are testing the same versions?
>
>
> I have downloaded the zeranoe build marked as 1.1.3 and I also got 
> http://ffmpeg.org/releases/ffmpeg-1.1.3.tar.bz2 and built that 
> myself.. so I would say it's the same version. However I got the same 
> problem with previous versions too (tried 1.0.1, and 1.1 for example).
>
>     Did you try to disable optimizations?
>
> For some reason I get build errors as soon as I 
> use --disable-optimizations:
>
> LDlibavutil/avutil-52.dll
>    Creating library libavutil/avutil.lib and object libavutil/avutil.exp
> cpu.o : error LNK2019: unresolved external symbol 
> _ff_get_cpu_flags_ppc referenced in function _av_get_cpu_flags
> cpu.o : error LNK2019: unresolved external symbol 
> _ff_get_cpu_flags_arm referenced in function _av_get_cpu_flags
> libavutil/avutil-52.dll : fatal error LNK1120: 2 unresolved externals
> make: *** [libavutil/avutil-52.dll] Error 1
>
> If I don't disable optimizations I don't get that and it builds 
> fine... but no idea about that (I have never really looked into the 
> ffmpeg code except for the public headers)
>


Parts of ffmpeg source code assume the compiler will remove the body of 
a conditional if the condition is always false, for example from 
libavutil.c/av_get_cpu_flags():

int av_get_cpu_flags(void)
{
     if (checked)
         return flags;

     if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
     if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
     if (ARCH_X86) flags = ff_get_cpu_flags_x86();

     checked = 1;
     return flags;
}


If ARCH_ARM is the constant 0, the code assumes this reference to 
ff_get_cpu_flags_arm() will disappear.  Treats that as an optimization, 
so if you turn off optimizations, the compiler will generate code to 
call ff_get_cpu_flags_arm, but that function won't exist if ARCH_ARM is 
false.

To get around that, I've used flags like these to compile a less 
optimized version for testing purposes:

--toolchain=msvc --optflags='-Zi -Og -Oy- -arch:SSE2' 
--extra-cflags='-Gy -MDd' --extra-ldflags='-OPT:REF -DEBUG -VERBOSE' 
--enable-shared

I've been using VC10.  The thing that's handy for me is that it 
generates .pdb files (via the -Zi flag) and I can mostly step through 
code with the VC10 debugger.

I had to modify the config.mak to get rid of some conflicting flags, 
running the configuration script would add -Z7 (which contradicts -Zi).  
It also would add -Oy which is the opposite of -Oy-, so I manually 
removed it.

--Johno

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130312/3bc4bfe1/attachment.html>


More information about the Libav-user mailing list