Problem with templates and Dll export

Discussion in 'C++' started by Marc André Ueberall, Jul 24, 2003.

  1. Hi there!

    I've got the following problem and would be very happy if there is somebody
    with a solution! =)

    Btw. I'm using Microsoft Visual C++ 6.0 Std Edition

    I've generated a template class called "CSingleton"

    template <class T>
    class __declspec(dllexport) CSingleton
    {
    static T *lpSingleton;

    public:
    CSingleton(void);
    ~CSingleton(void);

    static T &GetSingleton(void);
    static T *GetSingletonPtr(void);
    };

    Now I'm going to implement a texture manager (or whatever) like this

    class DUSKENGINE_API CTextureManager: public CSingleton<CTextureManager>
    {
    public:
    CTextureManager(void);
    ~CTextureManager(void);
    };

    When compiling this I get the following errors:

    ....
    CTextureManager.obj : error LNK2001: "public: __thiscall
    DuskEngine::Core::CSingleton<class
    DuskEngine::Renderer::CTextureManager>::CSingleton<class
    DuskEngine::Renderer::CTextureManager>(void)" (??0?$CSingleton@VCT
    extureManager@Renderer@DuskEngine@@@Core@DuskEngine@@QAE@XZ)
    CTextureManager.obj : error LNK2001: "public: __thiscall
    DuskEngine::Core::CSingleton<class
    DuskEngine::Renderer::CTextureManager>::~CSingleton<class
    DuskEngine::Renderer::CTextureManager>(void)" (??1?$CSingleton@VC
    TextureManager@Renderer@DuskEngine@@@Core@DuskEngine@@QAE@XZ)
    ....

    How do I export home-brew-templates and classes that are using them in a
    dll???

    Thank you for your comments!


    Marc André Ueberall
    Marc André Ueberall, Jul 24, 2003
    #1
    1. Advertising

  2. Marc André Ueberall

    Param Guest

    Hi
    I guess u are right exporting from a DLL is not defined...
    But u can try using explicit template instantiation where the Object for the
    class is created with some of the known types
    i.e. the writer of the class should be aware of the type of instantiations
    for that peculiar template class...

    This instantiation can be exported from the DLL and then u could use this
    class with no Linking errors...

    Paramjeet Singh


    "Victor Bazarov" <> wrote in message
    news:...
    > "Marc André Ueberall" <> wrote...
    > > ...
    > >
    > > How do I export home-brew-templates and classes that are using them in a
    > > dll???

    >
    > Exporting from a DLL is not defined by the C++ language. Please
    > post your compiler-specific question to microsoft.public.vc.language.
    >
    > Victor
    >
    >
    Param, Aug 18, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    8,702
  2. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,616
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  3. JKop
    Replies:
    3
    Views:
    468
  4. recover
    Replies:
    2
    Views:
    799
    recover
    Jul 25, 2006
  5. H. Simpson
    Replies:
    4
    Views:
    260
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page