tags:

views:

71

answers:

3

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.

+3  A: 

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.

Kyle Lutz
+4  A: 

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.

jbernadas
A: 

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.

Pavitar
You should have gotten a warning during the compile stage that there was no prototype for `AllALL` (and that the compiler was assuming a return type of `int`).
Ben Voigt
Your 'answer', Pavitar, should have been an amendment to the question - as I've done. You should also note @Ben Voigt's comment that if the compiler is generating warnings, you should heed them, and if the compiler is not generating warnings about missing prototypes, you have not got the compiler options set sensibly. You should probably delete this 'answer' now.
Jonathan Leffler
@Jonathan Leffler-Sir I didn't get you.As I'm just new to this whole programming world.Whatever I posted was what helped me to solve my error.
Pavitar
moved my comment to the question so it won't be lost if the answer is deleted.
Ben Voigt
Generally speaking, if you are the person asking the question on SO, you do not provide the answer to their own question; you amend the question to include the answer. This is not something that's absolutely mandated; indeed, the FAQ points out you can provide an answer to your own question. Often, newcomers do not realize they can edit their own question (once upon a year or more ago, they couldn't unless they'd gotten enough reputation). And you cannot accept your own answer for 48 hours; nor do you get any reputation out of accepting your own answer, which avoids people gaming the system.
Jonathan Leffler