起因是這樣的,本來想在我的VS2010上利用ffmpeg寫點東西,但是代碼才寫了一行,編譯通過但是運行之後就報如下問題,程序自動退出了。代碼和現象如下:
#include <stdio.h>
#include <iostream>
using namespace std;
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
};
int main(int argc, char* argv[])
{
av_register_all();
char szfilePath[100] = {"F:\\test\\ts.ts"};
system("pause");
return 0;
}
這個其實很不應該,畢竟什麼都沒有做,然後程序就這樣退出。
最終解決如下:
在項目屬性->連接器->優化->引用 原來的選項是:是 (/OPT:REF) 改成:否 (/OPT:NOREF)。然後就可以正常運行了。
解釋如下(不知道是否準確):