我是C语言初学者,遇到一个问题,找不到头文件,但其实这些头文件都在当前文件中,我看到网上的方法(例如:solution)都是加-I选项可以解决这个问题,但是我很好奇,为什么找不到自己,只能靠-i选项?
包括路径:
ls .
include test_ffmpeg.c
ls include/libavcodec/
avcodec.h avfft.h dirac.h dxva2.h vaapi.h vdpau.h videotoolbox.h xvmc.h
avdct.h d3d11va.h dv_profile.h qsv.h vda.h version.h vorbis_parser.h
源码树:root
|-----test_ffmpeg.c
|-----include
代码:#include <stdio.h>
#include "./include/libavcode/avcodec.h"
#include "./include/libvformat/acfomat.h"
#include "./include/libavfilter/avfilter.h"
int main(void)
{
return 0;
}
编译:gcc test_ffmpeg.c -lavcodec -lavdevice -lavfilter -lavformat -lavutil
发生 fatal error :test_ffmpeg.c:3:10: fatal error: ./include/libavcode/avcodec.h: No such file or directory
#include "./include/libavcode/avcodec.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
最佳答案
您的包含语句提到 include/libavcode
,但存在的路径是include/libavcodec
.
添加 c
你应该会看到不同。
关于c - 为什么找不到实际存在的头文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65298979/