Puzzling Linker error messages!

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??!!
> it did not compile!
yes, it did
http://www.cplusplus.com/forum/general/113904/


> is that I did NOT even use class newString in this particular program
run `nm' through your object files, and look who is asking for those symbols
by instance
1
2
3
4
5
for K in *.o; do
   if nm --demangle --undefined-only "$K" | grep newString > /dev/null; then
      echo "$K"
   fi
done

I read the article at the link you provided, while instructive, it would not help my situation since I am using an IDE. I knew it was a linkage problem; even going by the yardstick of what the article states, I am doing everything right so far.

The question remains where is the problem?!
Do cross-functional leaks occur between/among files within the same folder? Just a wild guess here since I can't for the life of me see what I am doing wrong!
> it would not help my situation since I am using an IDE
that was your choice, suffer by it. (it's not like you can't use the command line simply because you have an IDE)
if you want help on your IDE, one of the most important things to say is what IDE you are using.


> I can't for the life of me see what I am doing wrong!
I'm guessing that you are linking against an object file that is requiring those symbols.
maybe that object file shouldn't be part of your project and you "accidentally" include it. (e.g. with an include directory operation)
Topic archived. No new replies allowed.