当前位置:网站首页>Use of gcc/g++
Use of gcc/g++
2022-07-29 07:27:00 【Code loving students】
Catalog
2. gcc How to complete the conversion ?
Library is divided into static library and dynamic library
1. What is? gcc/g++?
gcc/g++ It's a compiler , Used to put C/C++ Language into machine language
2. gcc How to complete the conversion ?
Format :gcc [ Options ] Compiled files [ Options ] [ Target file ]
If it goes directly gcc [ Compile the file ] -o [ Target file ], The executable file will be directly generated
gcc Converting high-level language into machine language is divided into four steps :
1. Preprocessing
Pretreatment mainly includes four steps
- Expansion of header file
- Macro replace
- Note replacement
- Conditional compilation
Format :gcc -E test.c -o test.i
We can see that the pretreatment phase has completed all the steps we have mentioned
2. compile
The main function of compilation is to convert high-level language into assembly language
Format :gcc -S test.i -o test.s
Assembly language is more concise than high-level language
3. assembly
The most important step of compilation is to convert assembly language into binary language , That is, the machine recognizable code
Format :gcc -c test.s -o test.o
4. link
It's generating .o The end of the file marks the successful compilation , Then we need to link
Format :gcc test.o -o test
Here we need to cover an important knowledge point , That's why we link ?
We have compiled our code successfully , What is the role of links ?
We can find that in the code we write , Contains printf function , and print Is this function implemented by us ? Obviously not , Then we need to complete the implementation of this function when calling this function , And because we didn't complete the implementation of this function , But this function is implemented in the Library , Therefore, when we link, we are the linked libraries , So that we can complete the operation .
Library is divided into static library and dynamic library
Static library Refers to when compiling Links , Add all the implemented function code into the executable , Therefore, the generated file is relatively large , But in operation, there is no need to link library functions
Dynamic library Refers to when compiling Links , The implemented function code is not added to the executable , Instead, the required libraries are linked during the link , This can save space
stay Linux in , The default link is the dynamic library
And we can also actively link to static libraries
We found that when linking static libraries , The memory size is almost linked to the dynamic library 100 times
边栏推荐
- Thinkphp6 realizes database backup
- BeanUtils.setProperty()
- H3C_ Using setting default static routing priority to realize the active and standby function of export dual lines
- JS day 4 process control (if statement and switch statement)
- Zabbix 其他基础监控项
- Meta configuration item of route
- 在线问题反馈模块实战(十七):实现excel模板在线下载功能
- Introduction to logback filter
- 【暑期每日一题】洛谷 P1601 A+B Problem(高精)
- 请问flink支持sqlServer数据库么?获取sqlServer数据库的变化
猜你喜欢
It's enough for MySQL to have this article (disgusting and crazy typing 37k words, just for Bo Jun's praise!!!)
My personal website doesn't allow access to wechat, so I did this
亚马逊云助手小程序来啦!
Personal blog system (with source code)
以太网接口介绍
JS day 4 process control (if statement and switch statement)
在线问题反馈模块实战(十七):实现excel模板在线下载功能
CMOS芯片制造全工艺流程
js第四天流程控制(if语句和switch语句)
JS break and continue and return keywords
随机推荐
logback简介及引入方法
7-2 计算正五边形的面积和周长 (25分)
Using C language to skillfully realize the chess game -- Sanzi chess
【暑期每日一题】洛谷 P1601 A+B Problem(高精)
Paper reading (62):pointer networks
MySQL uses the client and select methods to view the summary of blob type fields
js第四天流程控制(if语句和switch语句)
对Vintage分析的一些学习理解
Use vscode to configure Mysql to realize connection, query, and other functions
Gin Middleware
作业7.28 文件IO与标准IO
使用自定义注解校验list的大小
2-统一返回类DTO对象
时钟树综合(一)
mysql 单表最多能存多少数据?
log4j Layout简介说明
我想问一下,我flink作业是以upsert-kafka的方式写入数据的,但是我在mysql里面去更
Why does ETL often become ELT or even let?
Gin parameter validation
QT连接两个qslite数据库报错QSqlQuery::exec: database not open