Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with templates and Dll export

Thread Tools

Problem with templates and Dll export

Marc André Ueberall
Posts: n/a
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;


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>

When compiling this I get the following errors:

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

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

Thank you for your comments!

Marc André Ueberall

Reply With Quote
Posts: n/a
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Marc André Ueberall" <(E-Mail Removed)> 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
> Victor

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM
samlib.dll / Export-NTDLL.DLL-RtlFreeUnicodeString Some1 Computer Support 8 04-01-2004 11:31 PM
Invalid export DLL or export format =?Utf-8?B?RGF2aWQgVmFsbGU=?= ASP .Net 0 10-29-2003 11:46 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM