Thread: Linker Error

  1. #1
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382

    Linker Error

    When trying to compile some source I downloaded (MSVC++ 6.0), I get 61 linker errors (unresolved external symbol). Clearly something is missing from my project. What could it be?

  2. #2
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Well...since you didn't give much to go by I can only assume that you don't know what "linking" is. So here is a short summary. When you click the compile button, the compiler generates object code (*.obj files). It generate one object file per .cpp/.c file that you have. When it is finished compiling, it must hook all those files together in a process called linking (the linker is actually a separate program). When you get unresolved external symbols, that means that some symbol, i.e. a function or a variable, was referenced in your code but was not found when the linking phase took place.

    Example:

    Code:
    void non_existent_function();
    int main()
    {
        // this will compile fine, but it won't link, because I didn't 
        // define non_existent_function.
        non_existent_function();
        return 0;
    }
    Now, in your particular case, I would guess that the code you downloaded references some code library on windows (maybe a .dll). In that case, the code will not be able to link, because by definition a .dll links in at run-time. But the linker is dumb, and it doesn't know that. So you need to help it out. You need to specify a .lib file in your project settings, so that the linker will realize that those functions it can't find are references to a dynamic library (dll).

    The settings can be found by clicking on Project/properties, and then clicking on "Linker", and "Command Line", and typing the .lib name in the "Additional Settings" edit box.

    I know that this doesn't exactly answer your question, because you are wondering right now exactly which lib file you should add. But you didn't tell us what any of the errors were either, so I can't help you there...
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  3. #3
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Err...Sorry the instructions for getting to project properties are for VC.NET 2003. I missed where you said you are using VC6. Maybe someone else can post how to get to the project settings on VC6, and adding additional .lib's on the link line?
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM