【问题标题】:error LNK1120: unresolved externals错误 LNK1120:未解决的外部问题
【发布时间】:2017-09-25 00:07:44
【问题描述】:

我正在尝试构建以下代码。但它给出的错误是“错误 LNK1120: 5 unresolved externals”。我在 Visual Studio 2013 中使用 C++。正确包含库。 avformat_open_input 方法出现错误。我在我的代码中使用 ffmpeg 中的复用。请帮忙。

const char *url = "H:/Sanduni_projects/ad_2.mp4";

AVFormatContext *s = NULL;
int ret = avformat_open_input(&s, url, NULL, NULL);
if (ret < 0)
    abort();

AVDictionary *options = NULL;

av_dict_set(&options, "video_size", "640x480", 0);
av_dict_set(&options, "pixel_format", "rgb24", 0);

if (avformat_open_input(&s, url, NULL, &options) < 0){
    abort();
}

av_dict_free(&options);

AVDictionaryEntry *e;

if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
    fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
    abort();
}

avformat_close_input(&s);

【问题讨论】:

  • 您应该在项目属性 -> 链接器 -> 输入处将库添加到您的项目中。
  • 已正确添加库

标签: c++ visual-studio ffmpeg


【解决方案1】:

问题已解决。我将此添加到代码中

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

【讨论】:

    【解决方案2】:

    我认为您在项目中缺少一些与库的链接。 Linking libavformat in Visual Studio 2010 将为您提供更多帮助。

    【讨论】:

      猜你喜欢
      • 2013-07-10
      • 1970-01-01
      • 2015-01-11
      • 2014-05-10
      • 2014-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      相关资源
      最近更新 更多