/usr/include/pthread.h:775: error: ‘clockid_t’ has not been declared

今天学FFmpeg开发,第一项目就出现问题。

按照一般的操作,在*.pro文件中添加头文件,库文件。

unix{

INCLUDEPATH += /usr/include 

LIBS += -L/usr/lib \
        -lavcodec -lavdevice -lavfilter -lavformat \
        -lavutil -lpostproc -lswresample -lswscale
}

linux下的FFmpeg头文件就在/usr/include目录下。

在*.h文件中添加

extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavdevice/avdevice.h"
}

编译报错:/usr/include/pthread.h:775: error: ‘clockid_t’ has not been declared

如果直接改成

unix{

INCLUDEPATH += /usr/include/libavcodec \
               .....

LIBS += -L/usr/lib \
        -lavcodec -lavdevice -lavfilter -lavformat \
        -lavutil -lpostproc -lswresample -lswscale
}

那么就会报错:stdlib.h找不到

可以看出这是由于/usr/include目录下头文件冲突造成的。

解决方法就是直接包含完整路径。

extern "C"{
#include "/usr/include/libavcodec/avcodec.h"
#include "/usr/include/libavformat/avformat.h"
#include "/usr/include/libswscale/swscale.h"
#include "/usr/include/libavdevice/avdevice.h"
}
发布了16 篇原创文章 · 获赞 21 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_26056015/article/details/103001941