Hello. I'm a first year CS student learning C++. I've been scouring this site over most of this semester, but this is the first time I've been totally stumped and I've reached the limitation of my Googling skills. I wrote a simple program for calculating a phone bill, but after working out all the errors I'm getting an error which I can not seem to find an answer to.
BTW I'm using vi editor in a Unix environment if that matters.
Here's the error I'm getting when trying to compile:
/tmp/cctC49Sp.o: In function `main':
phonebill.cc:(.text+0x4bb): undefined reference to `compute_call_cost_dollars(char, int, int, int)'
The "cctC49Sp" and "0x4bb" (that's hex, right? is it a memory location?) part change every time I attempt to compile it either with c++ or g++.
Listexec gives me a similar but slightly different error:
/tmp/ccURUYc4.o: In function `main':
phonebill.cc:(.text+0x4b5): undefined reference to
`compute_call_cost_dollars(char, int, int, int)'
collect2: ld returned 1 exit status
My question is what this error trying to tell me? I can post the code if need be and thank you in advance for any input or suggestions you might have.
It means that you tried to make a call to a function that was declared (its prototype is visible at the point of call, so no compiler error was produced), but not defined (its body wasn't written, or the file that contains it wasn't given to the linker). It happens most often when you simply forget to define the function, when you don't build the program right, when you change the definition or the declaration (for example, change some parameter type) but forget to update the other one, or when you put the declaration and definition of a template function in different files.
Ah, I'm an idiot. I typed compute_call_cost-dollar instead of compute_call_cost_dollars. Well, at least now I know what that is in case it happens again.