LNK 2019未解决的符号 - FFmpeg

时间:2013-02-19 23:17:08

标签: visual-studio-2010 ffmpeg lnk2019

我正在尝试使用FFmpeg打开并阅读视频.avi 我使用Visual Studio 2010在win7 x64上工作

现在我的代码非常简单:

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "SDL.h"
#include "SDL_mixer.h"


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

AVFormatContext *pFile_video;
int             s, videoStream;
AVCodecContext  *pCodecCtx;
AVCodec         *pCodec;
AVFrame         *pFrame; 
AVFrame         *pFrameRGB;
AVPacket        packet;
int             frameFinished;
int             numBytes;
uint8_t         *buffer;

av_register_all();

    if((avformat_open_input(&pFile_video, "AR.avi", NULL,NULL)!=0)) cout <<"cannot open video file"<<endl;
    //if(av_find_stream_info(pFile_video) <0) cout <<"cannot retrive stream information"<<endl;

    videoStream =-1;
    for(s=0; s<pFile_video->nb_streams;s++){
        if((pFile_video->streams[s]->codec->codec_type) == AVMEDIA_TYPE_VIDEO) videoStream =s;
    }
    if(videoStream ==-1) cout <<"cannot open video stream"<<endl;

f(SDL_Init(SDL_INIT_EVERYTHING)< 0) cout<< "cannot initialize SDL subsystems"<<endl;
    if(Mix_OpenAudio(22050,MIX_DEFAULT_FORMAT,2, 4096) <0) cout <<"error mixer audio"<<endl;
    music = Mix_LoadMUS("AR.wav");
    if(music == NULL) {cout <<"error loading music    "<<endl;
}

return 0;
}

我链接了以下.lib文件:

avcodec.lib
avdevice.lib
avfilter.lib
avformat.lib
avutil.lib
postproc.lib
swresample.lib
swscale.lib

但我收到了这些错误:

>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: la libreria predefinita 'msvcrt.lib' è in conflitto con l'utilizzo di altre librerie; utilizzare /NODEFAULTLIB:libreria
1>main_video_ffmpeg.obj : error LNK2019: riferimento al simbolo esterno "int __cdecl avformat_open_input(struct AVFormatContext * *,char const *,struct AVInputFormat *,struct AVDictionary * *)" (?avformat_open_input@@YAHPAPAUAVFormatContext@@PBDPAUAVInputFormat@@PAPAUAVDictionary@@@Z) non risolto nella funzione _SDL_main
1>main_video_ffmpeg.obj : error LNK2019: riferimento al simbolo esterno "void __cdecl av_register_all(void)" (?av_register_all@@YAXXZ) non risolto nella funzione _SDL_main
1>C:\Users\Cristina\Desktop\OpenCV\Progetti\MIEI_PROGETTI_Vs\video_ffmpeg\Debug\video_ffmpeg.exe : fatal error LNK1120: 2 esterni non risolti

我认为这是一个链接器错误..但我没有FFmpeg库的其他.lib文件。

1 个答案:

答案 0 :(得分:3)

你应该用extern“C”包围你的ffmpeg包含

    extern "C" {
      #include "libavcodec/avcodec.h"
      #include "libavformat/avformat.h"
      #include "SDL.h"
      #include "SDL_mixer.h"
    }