c - 这个 `ld` 错误 ("undefined reference") 是什么意思?

标签 c

这个错误是什么意思?

/tmp/ccevEqoI.o: In function `main':
funcptr.c:(.text+0x61): undefined reference to `AddALL'
collect2: ld returned 1 exit status

我正在尝试编写一个将所有整数相加到极限的函数 由用户输入。


转录的“答案”是来自 OP 的评论:

I wrote a program that would add all the integers upto the limit Specified. For that I had to write a function. So I made a function called 'AddAll' but when I called it from my program I called it as 'AddALL'.

Note: C is case sensitive. Eventually when I changed the name of the function where I was calling it. It compiled perfectly :)

Just thought that this piece of info would be useful to beginners.

最佳答案

这意味着链接器(在 gcc 中称为 ld)没有在指定的目标文件中找到符号 AddALL。基本上,该函数没有主体,或者它是一个声明为 extern 且没有定义的变量。

关于c - 这个 `ld` 错误 ("undefined reference") 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3572043/

相关文章:

c - 在 C 中使用数组索引的 scanf

c - 如何从高架摄像机考虑建筑物轨迹中像素的旋转?

c - 点在矩形内

c - 为什么会发生这种情况的想法? printf 让我的代码工作

c - 带有 `df` 的可用 block

c - 如何在 OpenMP 并行区域内声明和 malloc 指针? (错误 : Segment violation ('core' generated))

c - 使用指向指针的指针访问结构中的指向指针的指针

c - 在 C 中支持和使用 `fortran` 关键字

c - C中的结构初始化问题

c - 如何定位段错误的根源? (CS50 : recover.c)