c++ - 使用 ffmpeg 无法解析的外部符号

标签 c++ c ffmpeg linker-errors unresolved-external

<分区>

我刚刚下载了 ffmpeg 的开发包,并正在设置头文件和库以供使用。我使用的是 Visual C++ 2013,我添加了 ffmpeg 头文件和库的路径。我链接到 ffmpeg lib 文件夹中的每个 lib 文件,显然它们都不匹配 av_register_allavformat_open_input

这是尝试构建的输出:

1>------ Build started: Project: ffmpeg_learning, Configuration: Debug Win32 ------
1>  ffmpeg_learning.cpp
1>ffmpeg_learning.obj : error LNK2019: unresolved external symbol _av_register_all referenced in function _main
1>ffmpeg_learning.obj : error LNK2019: unresolved external symbol _avformat_open_input referenced in function _main
1>c:\users\edward severinsen\documents\visual studio 2013\Projects\ffmpeg_learning\Debug\ffmpeg_learning.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这是我的代码:

#include "stdafx.h"

extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
}

#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "avdevice.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "avfilter.lib")
#pragma comment(lib, "postproc.lib")
#pragma comment(lib, "swresample.lib")

int main(int argc, char* argv[])
{
    av_register_all();

    AVFormatContext* pFormatCtx = NULL;

    //Open video file
    if (avformat_open_input(&pFormatCtx, argv[1], NULL, 0))
    {
        //Couldn't open the file
        return -1;
    }

    return 0;
}

我不知道我错过了什么。任何帮助将非常感激。谢谢。

最佳答案

根据所提供的信息,我只能提出一般性建议。我将尝试指出它们的相对重要性。

1) VC++ 2013 可能有点过时了。这可能是您遇到的最少的问题。您始终可以尝试按此顺序在 Linux 或 OSX 上构建 FFMPEG 版本。它最容易在 Linux 上构建。然后您可以在 Windows 构建环境中“移植”或复制这些步骤。您还可以尝试使用 MSYS2 在 Windows 上创建模仿 Linux 的构建环境。

2) 确保获得最新稳定版本的 FFMPEG。报告问题时,请务必提及版本,并显示 ffmpeg 命令的输出。

3) 根据以上内容,您可能遇到了库版本不匹配的问题。它似乎只找到了两个丢失的符号。 VisualC++ 应该有像“strings”、“objdump”和“nm”这样的工具,它们可以让你查看库文件的内容,看看你是否真的有想要的符号。

关于c++ - 使用 ffmpeg 无法解析的外部符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48999820/

相关文章:

c++ - Arduino中的 vector

c++ - 为什么删除 End-Iterator 不会导致 Segmentation Fault with shared_ptr?

c - 在 C 中返回 int 数组

c - 在 C 中使用 read 打印 "hello world!"

php - FFMPEG 检索持续时间不适用于 MOV 文件

video - 对于无损视频压缩,哪个更好? crf还是qp?

c++ - 奇怪的列表打印函数行为。如果我打印 "\n"则有效,如果删除它则无效

c++ - 简单的游戏,while 循环和检查字符串

c - 返回值显示到屏幕时的函数错误

远程分支中特定文件行的下一次更改的 Git 日志