Linker Problem

Ravishankar S
Sun Sep 17 04:57:00 GMT 2006


The problem could be because you are trying to compile and link every
file, instead of compiling every file and link all the object files at
the end.


-----Original Message-----
From: [] On
Behalf Of
Sent: Sunday, September 17, 2006 2:39 AM
Subject: Linker Problem

I am having a problem with the linker. When the linker reaches this bit
It displays the following message:
  [Linker error] undefined reference to `Account::setAccountNumber(int)'

This bit of code appears in a function I have placed in the main.cpp
file. I have several other similar lines of code in other such
functions, and all are giving me the same error. All of these such
functions are called by main(), and all are prototyped and implemented
within the main.cpp file. 
I thought that maybe anAccount was out of scope, but that does not seem
to be the case. I had to declare it as a global variable, since
declaring it directly in main resulted in it not being visible to my
other functions. However, declaring it this way does not result in the
linker error, although I believe that these errors appear before the
linker is reached, so I do not know if the linker errors would still
exist if I could devise another way of declaring anAccount so that it
would stay in scope. Any help you could provide would be greatly
Joe Hayes

__________ NOD32 1.1454 (20060321) Information __________

This message was checked by NOD32 antivirus system.

More information about the Gcc-help mailing list