当前位置:网站首页>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
边栏推荐
- @RequestMapping 用法详解
- I'd like to ask, my flick job writes data in the way of upsert Kafka, but I'm more careful in MySQL
- Ansible中的变量及加密
- 以太网接口介绍
- 1-后台项目搭建
- 请问flink支持sqlServer数据库么?获取sqlServer数据库的变化
- 树莓派的启动流程
- Scala higher order (10): exception handling in Scala
- Leetcode 209. subarray with the smallest length (2022.07.28)
- jdbc入门
猜你喜欢
Scala 高阶(十):Scala中的异常处理

Variables and encryption in ansible

MySQL - multi table query

Vite3.0 has been released, can you still roll it (list of new features)

Personal blog system (with source code)

1-后台项目搭建

MySQL 使用客户端以及SELECT 方式查看 BLOB 类型字段内容总结

WPF nested layout case

Error 1045 (28000) access denied for user 'root' @ 'localhost' solution
![[OpenGL] use of shaders](/img/73/1322afec8add6462ca4b82cb8112d1.png)
[OpenGL] use of shaders
随机推荐
Kubernetes (V) -- deploy kubernetes dashboard
Tp6 use protobuf
5-整合swagger2
Round avatar of user list and follow small blocks
Other basic monitoring items of ZABBIX
CDC source can quit after reading MySQL snapshot split
Summer summary (II)
Can I specify memory parameters in SQL statements?
LevelFilter简介说明
Use vscode to configure Mysql to realize connection, query, and other functions
Scala 高阶(十):Scala中的异常处理
Ansible中的变量及加密
Reflect reflect
微服务远程调用
Nodejs installation tutorial
Excel file reading and writing (creation and parsing)
【WPF】通过动态/静态资源实现语言切换
Gin service exit
NPM install reports an error NPM err could not resolve dependency NPM err peer
1-后台项目搭建