This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Linker Problem


Hi,

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.

Regards,
Rvaishankar

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of joe_squid@sbcglobal.net
Sent: Sunday, September 17, 2006 2:39 AM
To: gcc-help@gcc.gnu.org
Subject: Linker Problem


I am having a problem with the linker. When the linker reaches this bit
of
code:
 
    anAccount[arrayPosition].setAccountNumber(acctNum);
 
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
appreciated.
 
 
 
Thanks,
Joe Hayes

__________ NOD32 1.1454 (20060321) Information __________

This message was checked by NOD32 antivirus system. http://www.eset.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]