undefined reference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ice8595
    New Member
    • Mar 2007
    • 13

    undefined reference

    Hi there,

    I'm relatively new at C++ and I'm wondering if I can get some help on this error I'm having. I'm trying to run this sample code I have that should be correct. All of my files compile successfully, but when I try to run them, I get the following error:

    g++.exe C:\DOCUME~1\Own er\Desktop\499\ Main.o -o C:\DOCUME~1\Own er\Desktop\499\ Main.exe -Wall -fpermissive -Wno-sign-compare -g
    C:\DOCUME~1\Own er\Desktop\499\ Main.o: In function `main':
    //C/DOCUME~1/Owner/Desktop/499/Main.cpp:11: undefined reference to `Name::Name(cha r *)'
    //C/DOCUME~1/Owner/Desktop/499/Main.cpp:12: undefined reference to `Name::print(vo id)'
    Failure

    I have the class Name separated into .h and .cpp file and I'm running the program on a separate main method file main.cpp.
    I am using compiler Jens' File Editor - GCC.

    I'd really appreciate any help I can get....since I can't get anywhere on any programs with this error.

    Thanks
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    sounds like you need to link the files together, e.g. at the command line
    gpp main.cpp name.cpp

    or if you are using an IDE add both .cpp files to the project

    Comment

    Working...