当前位置:网站首页>GCC编译的时候头文件搜索规则
GCC编译的时候头文件搜索规则
2022-08-05 10:16:00 【小果壳】
1、GCC搜索头文件规则
首先gcc会从当前目录寻找所需要的头文件,一般是用户自定义的头文件。
gcc会根据 -I 参数指定的头文件路径 来搜索头文件,如下,头文件路径为/usr/openwin/include,/srv/lib为动态库路径。
gcc -I /srv/include -L /srv/lib hello.c
gcc从自身的环境变量C_INCLUDE_PATH、CPLUS_INCLUDE_PATH、OBJC_INCLUDE_PATH 中寻找所需要的头文件
从内定目录 /usr/include /usr/local/include /usr/lib/gcc-lib/i386-li中寻找所需要的头文件。
都找不到时 就会报错。
2、在makefile中指定头文件路径
#编译器的路径
CC= /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
#指定头文件路径,提示警告编译,
CFLAGS=-Wall -I/home/develop/include
#源文件路径
SRCS=main.c sum.c com.c
#动态库路径
LIBS=-L /usr/lib
#指定目标文件,所有的.c文件改名为.o文件(保留%处的字符,其余字符要替换)
OBJS=$(SRCS:%.c=%.o)
#指定可执行文件的名字
EXECUTABLE=ssj_flyfish
#编译生成目标文件
$(EXECUTABLE):
$(CC) -o $(EXECUTABLE) $(CFLAGS) $(SRCS) $(LIBS)
边栏推荐
- 茄子科技CEO仇俊:以用户为中心,做用户真正需要的产品
- ffmpeg drawtext 添加文本水印
- 微服务 技术栈
- 百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意
- 语音社交软件开发——充分发挥其价值
- First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
- MySQL事务
- 第四章:redis 数组结构的set和一些通用命令「建议收藏」
- Keil升级到AC6后,到底有哪些变化?
- 基于MindSpore高效完成图像分割,实现Dice!
猜你喜欢
three.js debugging tool dat.gui use
阿里全新推出:微服务突击手册,把所有操作都写出来了PDF
IDEA performs the Test operation, resulting in duplicate data when data is inserted
Egg framework usage (2)
多线程(进阶) - 2.5w字总结
linux下oracle常见操作以及日常积累知识点(函数、定时任务)
我们的Web3创业项目,黄了
PCB布局必知必会:教你正确地布设运算放大器的电路板
5. Deploy the web project to the cloud server
什么是CRM决策分析管理?
随机推荐
What is SPL?
MySQL data view
微服务 技术栈
Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
uniapp connect ibeacon
我们的Web3创业项目,黄了
电气工程的标准是什么
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
What is the function of the regular expression replaceAll() method?
mysql索引
七夕浪漫约会不加班,RPA机器人帮你搞定工作
Bias lock/light lock/heavy lock lock is healthier. How is locking and unlocking accomplished?
three objects are arranged in a spherical shape around the circumference
High-quality DeFi application building guide to help developers enjoy DeFi Summer
IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
FPGA:基础入门LED灯闪烁
MySQL transactions
[Android]如何使用RecycleView in Kotlin project
产品太多了,如何实现一次登录多产品互通?
【AGC】增长服务1-远程配置示例