c++ - 尝试使用 ffmpeg 的 Unresolved external

标签 c++ linker ffmpeg

我正在尝试使用 ffmpeg 中的一些函数,但遇到了弹性链接器错误。这是我所做的:

  • http://ffmpeg.zeranoe.com/builds/ 下载了最新的 32 位“开发”版本(即 ffmpeg-20130418-git-ee94362-win32-dev)
  • 在 Visual Studio 2012 Premium 中创建了一个“General - empty”C++ 项目
  • 将 [ffmpeg]/lib 文件夹添加到链接器 -> 输入 -> “其他库目录”
  • 添加了“swscale.lib;avutil.lib;avformat.lib;avdevice.lib;avcodec.lib;”到链接器 -> 输入 -> “附加依赖项”
  • 在 C++ -> General -> Additional Include Directories 下添加了以下内容:
    • [ffmpeg]/包含
    • [ffmpeg]/include/libswscale
    • [ffmpeg]/include/libav格式

这是我的 main.cpp:

#include "avformat.h"

int main()
{
    av_register_all();
} 

这失败了:

error LNK2019: unresolved external symbol "void __cdecl av_register_all(void)" (?av_register_all@@YAXXZ) referenced in function _main

我该如何修复这个错误?

最佳答案

当你使用 C++ 时,你需要用 extern "C" 包围你的 ffmpeg #include 语句,如下所示:

extern "C"
{
    #include "avformat.h"
}

关于c++ - 尝试使用 ffmpeg 的 Unresolved external ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16150211/

相关文章:

asp.net - ffmpeg 读取文件大小

c++ - 使用 istream 从命名管道读取

linux - 如何告诉 mex 链接到/usr/lib 中的 libstdc++.so.6 而不是 MATLAB 目录中的那个?

FFmpeg 幻灯片问题

c++ - 在编译一个简单的 Ceres Solver 演示时,是什么让 clang 而不是 g++ 绊倒了?

c++ - 除非链接到 pthreads,否则不会出现死锁?

带有movi3ed的RGL视频

c++ - FLTK Fl_Scrollbar 问题

c++ - 带有 const 指针的 vector 构造函数示例

c++ - 最多只能打印数组的条目两次