David Tree David Tree - 1 year ago 79
C++ Question

I am really confused with this kind of compilation error( C ffmpeg Qt)

I downloaded the latest ffmpeg source code and successfully installed it on Ubuntu
But I failed to compile a simple demo.(I did included proper headers)

Here are the error messages ,just to name a few:

error: unknown type name 'AVFrame'

error: 'NULL' undeclared (first use in this function)

error: request for member 'streams' in something not a structure or union

error: 'AVMEDIA_TYPE_VIDEO' undeclared (first use in this function)

error: expected expression before ')' token

Can you help me solve this problem?

Contents Added:

e.g this is my includes

extern "C"{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/avutil.h>

int main(int argc, char *argv[]) {
AVFormatContext *pFormatCtx;
int i, videoStreamIdx;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
AVFrame *pFrameRGB;

e.g AVFormatContext is declared in /usr/include/libavformat/avformat.h
error message box shows Unknown type name AVFormatContext
But How could it possibly be?

Answer Source

In Qt you can add this line to your .pro file to force the compiler to look there for header files. Change it to the folder where your header files are stored.

INCLUDEPATH += <your path>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download