Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this `ld` error ("undefined reference") mean?

Tags:

c

What does this error mean?

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

I'm trying to write a function which adds all the integers up to the limit entered by the user.


Transcribed 'answer' which is a comment from the 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.

like image 481
Pavitar Avatar asked Aug 26 '10 04:08

Pavitar


2 Answers

It means that the linker (that is called ld in gcc) did not found the symbol AddALL in the specified object files. Basically, there is no body for that function or it's a variable declared as extern with no definition.

like image 79
jbernadas Avatar answered Oct 04 '22 22:10

jbernadas


It tells you that the definition for the function 'AddALL' could not be found. Make sure that you include the object file that contains 'AddALL' when you compile/link.

like image 34
Kyle Lutz Avatar answered Oct 04 '22 22:10

Kyle Lutz