当前位置:网站首页>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 .
边栏推荐
- R语言使用order函数对dataframe数据进行排序、基于单个字段(变量)进行降序排序(DESCENDING)
- Modulenotfounderror: no module named 'PIL' solution
- R语言dplyr包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组均值(mean)
- A method of removing text blur based on pixel repair
- ModuleNotFoundError: No module named ‘PIL‘解决方法
- Pytorch common loss function
- Digital "new" operation and maintenance of energy industry
- 三面蚂蚁金服成功拿到offer,Android开发社招面试经验
- RT-Thread 组件 FinSH 使用时遇到的问题
- Multithreading Basics: basic concepts of threads and creation of threads
猜你喜欢
[depth first search] Ji suanke: Square
Detailed idea and code implementation of infix expression to suffix expression
openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
用于远程医疗的无创、无袖带血压测量【翻译】
pytorch常见损失函数
三年Android开发,2022疫情期间八家大厂的Android面试经历和真题整理
如何提高网站权重
Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
助力安全人才专业素养提升 | 个人能力认证考核第一阶段圆满结束!
Method of accessing mobile phone storage location permission under non root condition
随机推荐
Oracle advanced (IV) table connection explanation
AutoCAD - what is the default lineweight for centerline drawing and CAD? Can I modify it?
Benefit a lot, Android interview questions
test about BinaryTree
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
GCC【7】- 编译检查的是函数的声明,链接检查的是函数的定义bug
Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth
LeetCode-1279. 红绿灯路口
Sanmian ant financial successfully got the offer, and has experience in Android development agency recruitment and interview
pytorch常见损失函数
A method of removing text blur based on pixel repair
C#/VB. Net to add text / image watermarks to PDF documents
C language daily practice - day 22: Zero foundation learning dynamic planning
包装行业商业供应链管理平台解决方案:布局智慧供应体系,数字化整合包装行业供应链
Multithreading Basics: basic concepts of threads and creation of threads
Computer network: sorting out common network interview questions (I)
业务与应用同步发展:应用现代化的策略建议
Online notes
驼峰式与下划线命名规则(Camel case With hungarian notation)
R language ggplot2 visualization: use the ggstripchart function of ggpubr package to visualize the grouped dot strip plot, and set the add parameter to add box plots for different levels of dot strip