Hey guys,
I am writing an address book program. It has multiple header files and their corresponding implementation files. The program compiled and ran perfectly fine when I had all the header files, implementation files, non-class-member functions, and function main() all lumped together in one huge .cpp file. However, when I used the project implementation format where each header file(.h file), implementation file(.cpp file), and function main() had to be added to a project (.dev file), it did not compile! It came up with several
[Linker error] undefined reference to ' . . . ' error messages. Shown below is the block of error messages I got after compilation:
[Linker error] undefined reference to `nodeType<extPersonType>* middleNode<extPersonType>(nodeType<extPersonType>*, nodeType<extPersonType>*)'
[Linker error] undefined reference to `newString::~newString()'
[Linker error] undefined reference to `newString::~newString()'
[Linker error] undefined reference to `newString::~newString()'
[Linker error] undefined reference to `newString::operator=(newString const&)'
[Linker error] undefined reference to `newString::operator=(newString const&)'
ld returned 1 exit status
F:\C++PROJECTS\Makefile.win [Build Error] [QN17-1.exe] Error 1 |
One of the most astonishingly baffling things to me is that I did
NOT even use class
newString in this particular program; I used it in some other programs!! Hence, it is incredibly puzzling to me why the last five Linker error messages that are
newString-related would even appear in the first place!! Although I must say the header and implementation files for class
newString are resident in my C++PROJECTS folder. Just to see what would happen, when I added the
newString header and implementation files to the project, it worked! But why should this be when I did not use it anywhere in the program?
Does anyone really know what is going on, please??!!