c - 为什么找不到实际存在的头文件?
问题描述
我是C语言初学者,遇到一个问题,找不到头文件,但其实这些头文件都在当前文件中,我在网上看到的方法(例如:解决方案)都是加-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
发生致命错误:
test_ffmpeg.c:3:10: fatal error: ./include/libavcode/avcodec.h: No such file or directory
#include "./include/libavcode/avcodec.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
解决方案
您的 include 语句提到include/libavcode
,但存在的路径是include/libavcodec
.
添加一个c
,您应该会看到不同。
推荐阅读
- python - 图表有什么问题
- python - 用 Python 编写 Discord 机器人 - 如何让它自动发送消息?
- java - RateLimiter 仅适用于某些方法
- nix - 覆盖 Nix 中的服务定义?
- javascript - 按属性分组 div
- django - Django Rest 框架作为单点登录
- ipython - fastapi 中的烧瓶 python manage.py shell 等效项
- sympy - sympy 可以在分母中将表达式与 Heaviside 集成吗?
- javascript - 如何使用top,gg vote webhook?
- string - Netlogo 中是否有多行字符串语法?