1

/INCREMENTAL:NO是视觉 c 中发布配置的默认值。

我已经FFmpeg git-3efe5e3 32-bit Devhttp://ffmpeg.zeranoe.com/builds/下载了。它包含.dll.a.lib文件。我选择了.lib。编译后 ffmpeg dll 的导入表为空,程序崩溃。如果我启用/INCREMENTAL,它可以编译并运行良好。

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
...
4

1 回答 1

1

这是一个已知的错误,binutils在 FFmpeg 的 Zeranoe 版本中使用。默认情况下,在 Microsoft Visual Studio 的发布版本中,链接器选项 > 优化 > 引用 =/OPT:REF会去除所有 FFmpeg 引用,因此您不会在dumpbin /IMPORTS.

您需要按照说明4.2.1 Linking to FFmpeg with Microsoft Visual C++。有两种选择。要么/OPT:NOREF在链接器选项中指定由于增加可执行文件大小而不推荐的选项,并增加可执行文件的初始加载时间。或者生成新的.lib.exp文件.def,例如,对于 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

另一种选择是自己构建 FFmpeg。

另一种选择是加入 FFmpeg 开发社区并将构建系统从 autotools/autoconf/automake 转移到 CMake。

版主,请修复我损坏的英语。

于 2014-02-03T13:09:34.217 回答