Question

/INCREMENTAL:NO is default for Release configuration in visual c.

I've downloaded FFmpeg git-3efe5e3 32-bit Dev from http://ffmpeg.zeranoe.com/builds/ . It contains .dll.a and .lib files. I chose .lib. After compile the import tables for ffmpeg dlls are empty and the program crashes. If I enable /INCREMENTAL, it compiles and runs fine.

test.c:

void av_register_all();

int main() {
    av_register_all();
    return 0;
}

_

lib>cl test.c /link /incremental:no avformat.lib ws2_32.lib
lib>dumpbin /IMPORTS test.exe
...
    avformat-55.dll
                4080F4 Import Address Table
                4095E4 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference


    KERNEL32.dll
                408000 Import Address Table
                4094F0 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                  143 GetCurrentProcessId
                  110 GetCommandLineA
                  216 HeapFree
...
Was it helpful?

Solution

It is a known bug in binutils which is being used in Zeranoe builds of FFmpeg. In Release builds of Microsoft Visual Studio by default in Linker options > Optimization > References = /OPT:REF which strips all FFmpeg references so you don't see them in dumpbin /IMPORTS.

You need to follow instructions 4.2.1 Linking to FFmpeg with Microsoft Visual C++. There are two options. Either specify /OPT:NOREF in linker options which is not recommended due to increase of the size of an executable and increase initial loading time of an executable. Or generate new .lib and .exp files from .def, for example, for x86_64:

lib /machine:x64 /def:avcodec-55.def /out:avcodec.lib
lib /machine:x64 /def:avdevice-55.def /out:avdevice.lib
lib /machine:x64 /def:avfilter-4.def /out:avfilter.lib
lib /machine:x64 /def:avformat-55.def /out:avformat.lib
lib /machine:x64 /def:avutil-52.def /out:avutil.lib
lib /machine:x64 /def:postproc-52.def /out:postproc.lib
lib /machine:x64 /def:swresample-0.def /out:swresample.lib
lib /machine:x64 /def:swscale-2.def /out:swscale.lib

Another option is to build FFmpeg by youself.

Another option is to join FFmpeg dev community and move build system from autotools/autoconf/automake to CMake.

Moderators, please fix my broken english.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top