Run-Time vs Load-Time linking question. - Programmer

This is a discussion on Run-Time vs Load-Time linking question. - Programmer ; Hi, I have written a DLL and an application that uses it. Its basically a wrapper dll that wraps a lib that requires lots of header files that you need a license to use blah blah.. My application access the ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Run-Time vs Load-Time linking question.

  1. Run-Time vs Load-Time linking question.

    Hi,
    I have written a DLL and an application that uses it. Its basically a
    wrapper dll that wraps a lib that requires lots of header files that
    you need a license to use blah blah..
    My application access the DLLs factory via the only exported function:
    In the DLL header file I have only:

    extern "C" __declspec(dllimport) protime::CFactory* createFactory();

    This CFactory can then create all the other classes I need, and I can
    create and use the functions in those classes without needing explicit
    exports.
    I do it like this:

    typedef Factory* (*PFcreateFactory)();
    PFcreateFactory createFactory = (PFcreateFactory)
    GetProcAddress(mydll,"createFactory");
    m_factory = createFactory();

    So far so good, I can then go on and do something like:

    m_checker = m_factory->createChecker();

    Even though createChecker isnt exported.

    Now heres where it gets interesting when I try and switch to load-time
    linking.
    I can go straight to this step (provided the header file is included,
    and the .lib is linked in):

    m_factory = createFactory(); // Without needing the GetProcAddress

    But why cant I then go on and do a:

    m_checker = m_factory->createChecker();

    I get a linker error message like public: class protime::IChecker *
    __thiscall protime::CFactory::createChecker(void)"
    (?createChecker@CFactory@protime@@QAEPAVIChecker@2 @XZ)

    Why can I call createChecker in the former case without needing to
    GetProcAddress when I have to have it explicitly exported in the
    latter case?

    The whole point of me using a factory was that I only needed to export
    one function, and not every single function in every single class that
    the factory can create.

    Is that what I would have to do in order to use load-time linking?
    Really go through and export every function in every class? Or am I
    better off sticking with the run-time linking? Or is there something
    else I have missed?

    Thanks a lot.

    Kurt


  2. Re: Run-Time vs Load-Time linking question.

    Ahh the fact I couldnt link in the second case had nothing to do with
    whether I was load time or run time linking, it was simply a case of
    missing the virtual keyword in the header file, although how that makes
    a difference at link time I have no idea...


    kza wrote:
    > Hi,
    > I have written a DLL and an application that uses it. Its basically a
    > wrapper dll that wraps a lib that requires lots of header files that
    > you need a license to use blah blah..
    > My application access the DLLs factory via the only exported function:
    > In the DLL header file I have only:
    >
    > extern "C" __declspec(dllimport) protime::CFactory* createFactory();
    >
    > This CFactory can then create all the other classes I need, and I can
    > create and use the functions in those classes without needing explicit
    > exports.
    > I do it like this:
    >
    > typedef Factory* (*PFcreateFactory)();
    > PFcreateFactory createFactory = (PFcreateFactory)
    > GetProcAddress(mydll,"createFactory");
    > m_factory = createFactory();
    >
    > So far so good, I can then go on and do something like:
    >
    > m_checker = m_factory->createChecker();
    >
    > Even though createChecker isnt exported.
    >
    > Now heres where it gets interesting when I try and switch to load-time
    > linking.
    > I can go straight to this step (provided the header file is included,
    > and the .lib is linked in):
    >
    > m_factory = createFactory(); // Without needing the GetProcAddress
    >
    > But why cant I then go on and do a:
    >
    > m_checker = m_factory->createChecker();
    >
    > I get a linker error message like public: class protime::IChecker *
    > __thiscall protime::CFactory::createChecker(void)"
    > (?createChecker@CFactory@protime@@QAEPAVIChecker@2 @XZ)
    >
    > Why can I call createChecker in the former case without needing to
    > GetProcAddress when I have to have it explicitly exported in the
    > latter case?
    >
    > The whole point of me using a factory was that I only needed to export
    > one function, and not every single function in every single class that
    > the factory can create.
    >
    > Is that what I would have to do in order to use load-time linking?
    > Really go through and export every function in every class? Or am I
    > better off sticking with the run-time linking? Or is there something
    > else I have missed?
    >
    > Thanks a lot.
    >
    > Kurt



+ Reply to Thread