unresolved symbols when linking with a static library - Programmer

This is a discussion on unresolved symbols when linking with a static library - Programmer ; Does anyone know where I can get info on the rules for creating static libraries in C++ (I am using Visual Studio 6.0)? Or can anyone answer the following questions: 1. I have globals that are coming up as unresolved ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: unresolved symbols when linking with a static library

  1. unresolved symbols when linking with a static library

    Does anyone know where I can get info on the rules for creating static
    libraries in C++ (I am using Visual Studio 6.0)? Or can anyone answer
    the following questions:

    1. I have globals that are coming up as unresolved in the library test

    application:

    aule_timer * system_timer;
    aule_keyboard * keyboard;

    (I seem to have fixed this by specifying them in my main module in the
    test app (instead of in the library module where I originally put them
    - but an explanation of the rules for this kind of thing would be
    useful)

    2. I have two static class variables that are also coming up as
    unresolved:

    class aule_window_manager {
    protected:


    static aule_window_manager * application_window_manager;
    static std::map identifier_map;
    static std::map handle_map;

    .... etc

    Robin.


  2. Re: unresolved symbols when linking with a static library

    I guess the unresolved symbols in questions are just declared, but not
    defined anywhere.

    Try the following:

    *** lib.h ***
    // Theses are declarations
    extern aule_timer * system_timer;
    extern aule_keyboard * keyboard;

    class aule_window_manager {
    protected:
    static aule_window_manager * application_window_manager;
    static std::map identifier_map;
    static std::map handle_map;
    };

    *** lib.cpp ***
    #include lib.h

    // define the items
    aule_timer * system_timer = NULL;
    aule_keyboard * keyboard = NULL;

    aule_window_manager * aule_window_manager::application_window_manager =
    NULL;

    std::map
    aule_window_manager::identifier_map;

    std::map aule_window_manager::handle_map;

    -------------------------

    Hope this will solve your problem.

    Philip


+ Reply to Thread