当前位置:网站首页>GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
2022-07-06 19:09:00 【Small snails in big cities】
Project scenario :
- I have a problem recently , Let's simplify :
// int xxx();
int main()
{
xxx();
}
- Compile the , Natural compilation, but , The message is :
[email protected]:~/taoge/cpp/test$ g++ -c main.cpp
main.cpp: In function ‘int main()’:
main.cpp:5:9: error: ‘xxx’ was not declared in this scope
xxx();
^
[email protected]:~/taoge/cpp/test$
- Open the above comment , obtain :
int xxx();
int main()
{
xxx();
}
- Compile the , Can you pass ? have a look :
[email protected]:~/taoge/cpp/test$ g++ -c main.cpp
[email protected]:~/taoge/cpp/test$
- Link up , Find out xxx() Undefined .
[email protected]:~/taoge/cpp/test$ g++ main.o
main.o: In function `main': main.cpp:(.text+0x5): undefined reference to `xxx()'
collect2: error: ld returned 1 exit status
So as to confirm the problems in the title .
My wonder at that time was , xxx Function has no definition , Can actually compile . It does . To distinguish between compilation and linking .
Take a closer look at the above English Tips , Compile not pass , It is shown that not declared, And the link doesn't pass , It is shown that undefined. therefore , At a glance .
边栏推荐
- 驼峰式与下划线命名规则(Camel case With hungarian notation)
- openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
- How word displays modification traces
- Oracle advanced (IV) table connection explanation
- 业务与应用同步发展:应用现代化的策略建议
- 涂鸦智能在香港双重主板上市:市值112亿港元 年营收3亿美元
- Leetcode topic [array] - 119 Yang Hui triangle II
- 五金机电行业供应商智慧管理平台解决方案:优化供应链管理,带动企业业绩增长
- LeetCode-1279. 红绿灯路口
- Helm deploy etcd cluster
猜你喜欢
星诺奇科技IPO被终止:曾拟募资3.5亿元 年营收3.67亿
Digital "new" operation and maintenance of energy industry
Help improve the professional quality of safety talents | the first stage of personal ability certification and assessment has been successfully completed!
[depth first search] Ji suanke: Square
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
Detailed idea and code implementation of infix expression to suffix expression
How to improve website weight
Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
About static type, dynamic type, ID, instancetype
Pychrm Community Edition calls matplotlib pyplot. Solution of imshow() function image not popping up
随机推荐
Tensorflow and torch code verify whether CUDA is successfully installed
Implementation of AVL tree
Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry
About NPM install error 1
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
R语言dplyr包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组均值(mean)
快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
Benefit a lot, Android interview questions
Crawling data encounters single point login problem
From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
Noninvasive and cuff free blood pressure measurement for telemedicine [translation]
Php+redis realizes the function of canceling orders over time
LeetCode-1279. Traffic light intersection
QPushButton绑定快捷键的注意事项
How are you in the first half of the year occupied by the epidemic| Mid 2022 summary
Analysis of frequent chain breaks in applications using Druid connection pools
基于蝴蝶种类识别
Precautions for binding shortcut keys of QPushButton
能源行业的数字化“新”运维
[translation] a GPU approach to particle physics