当前位置:网站首页>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 .
边栏推荐
- In 50W, what have I done right?
- 快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
- The list of people who passed the fifth phase of personal ability certification assessment was published
- RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
- tensorflow和torch代码验证cuda是否安装成功
- ROS自定义消息发布订阅示例
- Based on butterfly species recognition
- Detailed idea and code implementation of infix expression to suffix expression
- pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
- C#/VB. Net to add text / image watermarks to PDF documents
猜你喜欢
Interview assault 63: how to remove duplication in MySQL?
Summary of performance knowledge points
Method of accessing mobile phone storage location permission under non root condition
倒计时2天|腾讯云消息队列数据接入平台(Data Import Platform)直播预告
Handwritten online chat system (principle part 1)
Word如何显示修改痕迹
helm部署etcd集群
A method of removing text blur based on pixel repair
Pytorch common loss function
How are you in the first half of the year occupied by the epidemic| Mid 2022 summary
随机推荐
Airiot IOT platform enables the container industry to build [welding station information monitoring system]
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
RT-Thread 组件 FinSH 使用时遇到的问题
Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution
ModuleNotFoundError: No module named ‘PIL‘解决方法
test about BinaryTree
Deep circulation network long-term blood pressure prediction [translation]
Nuc11 cheetah Canyon setting U disk startup
Leetcode topic [array] - 119 Yang Hui triangle II
涂鸦智能在香港双重主板上市:市值112亿港元 年营收3亿美元
Helm deploy etcd cluster
Qlabel marquee text display
Based on butterfly species recognition
三年Android开发,2022疫情期间八家大厂的Android面试经历和真题整理
Implementation of AVL tree
R语言使用dt函数生成t分布密度函数数据、使用plot函数可视化t分布密度函数数据(t Distribution)
QPushButton绑定快捷键的注意事项
Noninvasive and cuff free blood pressure measurement for telemedicine [translation]
上海部分招工市場對新冠陽性康複者拒絕招錄
About NPM install error 1