错误LNK1120:未解析的外部

时间:2017-04-27 09:19:51

标签: c++ visual-studio ffmpeg

我正在尝试构建以下代码。但它将错误称为“错误LNK1120:5未解析的外部”。我在Visual Studio 2013中使用C ++。正确包含了库。 avformat_open_input方法出错。我在我的代码中使用了ffmpeg中的muxing。请帮忙。

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);

2 个答案:

答案 0 :(得分:2)

问题已解决。我把它添加到代码

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

答案 1 :(得分:0)

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

相关问题