当前位置:网站首页>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 .
边栏推荐
- QLabel 跑马灯文字显示
- pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
- R语言使用rchisq函数生成符合卡方分布的随机数、使用plot函数可视化符合卡方分布的随机数(Chi Square Distribution)
- 业务与应用同步发展:应用现代化的策略建议
- Unlock 2 live broadcast themes in advance! Today, I will teach you how to complete software package integration Issues 29-30
- Php+redis realizes the function of canceling orders over time
- Multithreading Basics: basic concepts of threads and creation of threads
- When visual studio code starts, it prompts "the code installation seems to be corrupt. Please reinstall." Solution to displaying "unsupported" information in the title bar
- R语言使用order函数对dataframe数据进行排序、基于单个字段(变量)进行降序排序(DESCENDING)
- AUTOCAD——中心线绘制、CAD默认线宽是多少?可以修改吗?
猜你喜欢

LeetCode-1279. 红绿灯路口

根据PPG估算血压利用频谱谱-时间深度神经网络【翻】

C#/VB. Net to add text / image watermarks to PDF documents

AUTOCAD——中心线绘制、CAD默认线宽是多少?可以修改吗?
![A wearable arm device for night and sleeveless blood pressure measurement [translation]](/img/fd/947a38742ab1c4009ec6aa7405a573.png)
A wearable arm device for night and sleeveless blood pressure measurement [translation]

全套教学资料,阿里快手拼多多等7家大厂Android面试真题

Xingnuochi technology's IPO was terminated: it was planned to raise 350million yuan, with an annual revenue of 367million yuan

Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry

Computer network: sorting out common network interview questions (I)

同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
随机推荐
朗坤智慧冲刺科创板:年营收4亿 拟募资7亿
A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
pytorch常见损失函数
Sanmian ant financial successfully got the offer, and has experience in Android development agency recruitment and interview
[matlab] Simulink the input and output variables of the same module cannot have the same name
The nearest library of Qinglong panel
Leetcode topic [array] - 119 Yang Hui triangle II
使用map函数、split函数一行键入多个元素
Test technology stack arrangement -- self cultivation of test development engineers
Analysis of frequent chain breaks in applications using Druid connection pools
Pychrm Community Edition calls matplotlib pyplot. Solution of imshow() function image not popping up
R语言使用dt函数生成t分布密度函数数据、使用plot函数可视化t分布密度函数数据(t Distribution)
Installation and management procedures
Synchronous development of business and application: strategic suggestions for application modernization
R language uses the order function to sort the dataframe data, and descending sorting based on a single field (variable)
On AAE
Detailed idea and code implementation of infix expression to suffix expression
Countdown 2 days | live broadcast preview of Tencent cloud message queue data import platform
Digital "new" operation and maintenance of energy industry