Thread: Link Error

  1. #1
    Burning in Hell! Luigi's Avatar
    Join Date
    Nov 2002
    Posts
    117

    Question Link Error

    I get several link errors when i try to compile my project..
    its a calculator which was working just fine when was on 1 cpp file..
    But i tried to split it in many cpp files and only one .h file..

    now it wont compile and dont say that my code is wrong..

    it just say:
    Link Error : undefined: 'Parser::ans' (data)
    Referenced from 'main' in main.cpp
    Referenced from 'Parser::prim(bool)' in parser.cpp

    Link Error : undefined: 'Parser::expression' (data)
    Referenced from 'Parser::prim(bool)' in parser.cpp

    Link Error : undefined: 'Lexer::temp_string' (data)
    Referenced from 'Parser::prim(bool)' in parser.cpp
    Referenced from 'Lexer::get_token()' in lexer.cpp
    Referenced from 'main' in main.cpp

    Link Error : undefined: 'Table::menu()' (code)
    Referenced from 'Parser::prim(bool)' in parser.cpp
    Referenced from 'main' in main.cpp

    Link Error : undefined: 'Table::table' (data)
    Referenced from 'Parser::prim(bool)' in parser.cpp
    Referenced from 'main' in main.cpp
    I tried it with code warrior and microsoft c++ 6.0
    they both give link error but explanation is somewhat different..

    any idea?
    what did I do wrong?
    Its the first time I get link errors so I dunno what to do.. :(
    Luigi


    // I use Xcode 1.1 && CodeWarrior 8.3
    // When on Mac Os X 10.3.2

    // I use Microsoft Visual C++ 6.0
    // When on windows XP

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    A link error means that even though each .cpp file compiled, the linker wasn't able to match up the functions that were called in one file with any other function defined in another file.

    In MSVC++ 6.0, make sure that all of your .cpp files (and .h files) have been added to the project. This will ensure that they are compiled and linked together when you build. If they are all part of the project already, then maybe when you transferred the code into separate files you forgot to transfer some of the function implementations.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM