当我尝试编译连接ffmpeg的头文件的cpp文件时:
#include <stdio.h>
#include <windows.h>
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
}
int main(int argc, char* argv[])
{
if(argc < 2)
{
printf("Usage: %s filename\n", argv[0]);
}
av_register_all();
return 0;
}
使用简单的命令编译时,我得到:
D:\gcc\bin>g++ -o a a.cpp
C:\users\root\Temp\ccC9UvT7.o:a.cpp:(.text+0x2a): undefined reference to 'av_register_all'
collect2.exe: error: ld returned 1 exit status
使用更复杂的我得到:
D:\gcc\bin>g++ -o a a.cpp -lavutil -lavformat -lavcodec -lz
d:/gcc/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot -lavutil
d:/gcc/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot -lavformat
d:/gcc/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot -lavcodec
d:/gcc/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot -lz
collect2.exe: error: ld returned 1 exit status
我该如何解决这个问题?