当前位置:网站首页>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.cgcc从自身的环境变量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)
边栏推荐
- FPGA:基础入门按键控制LED灯
- [Strong Net Cup 2022] WP-UM
- 【Unity】【UGUI】【在屏幕上显示文本】
- JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
- Open Source Summer | How OpenHarmony Query Device Type (eTS)
- Still looking for a network backup resources?Hurry up to collect the following network backup resource search artifact it is worth collecting!
- js hijacks the array push method
- QSS 选择器
- 【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
- Oracle 19.3 restart 环境
猜你喜欢

leetcode: 529. Minesweeper Game

阿里全新推出:微服务突击手册,把所有操作都写出来了PDF

Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need

three objects are arranged in a spherical shape around the circumference

2022华数杯数学建模A题环形振荡器的优化设计思路思路代码分享

SQL外连接之交集、并集、差集查询

egg框架使用(一)

three.js调试工具dat.gui使用

气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)

【温度预警程序de开发】事件驱动模型实例运用
随机推荐
上位机开发C#语言:模拟STC串口助手接收单片机发送数据
数据中台建设(十):数据安全管理
Getting started with Polkadot parachain development, this article is enough
产品太多了,如何实现一次登录多产品互通?
hcip BGP enhancement experiment
皕杰报表的下拉框联动
浅析WSGI协议
MySQL data view
What is CRM Decision Analysis Management?
[Strong Net Cup 2022] WP-UM
2022华数杯数学建模思路分析交流
Where is your most secretive personality?
第七章,activiti个人任务分配,动态指定和监听器指定任务委派人「建议收藏」
SQL外连接之交集、并集、差集查询
电竞、便捷、高效、安全,盘点OriginOS功能的关键词
Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
电气工程的标准是什么
C语言的高级用法
19. Server-side session technology Session
[Unity] [UGUI] [Display text on the screen]