Re: Visual C++ 6.0 DLL question

From: Blake (Blake_at_discussions.microsoft.com)
Date: 10/18/04


Date: Mon, 18 Oct 2004 08:15:02 -0700

This method works fine and dandy for regular classes, but what about template
classes? In VC++ 6.0, I found a template class has to be all in the header
file in order to compile, so I have my header file for the class and at the
end of the file I include the source file.
Now I want to include a few template classes in my DLL. I try doing the
method below but a get dozens of errors when compiling. I would like these
template classes to be in my DLL because I have other classes in the same DLL
that use these template classes. Is there any way to do this?

Thanks!
Blake

"Tim Robinson" wrote:

> Blake wrote:
> > Hi. I am trying to create a DLL that contains a bunch of classes and only
> > classes (basically no regular functions). I create a Win32 DLL empty project.
> > I then create a source file with the DLLEntry() function (code copied
> > directly from the documentation) and throw in my class header and source
> > files. I go to compile it and the DLL is generated but not LIB or EXP files
> > are created, which I need if I want to use my DLL in other projects.
> >
> > What do I need to add/change in my project to generate these LIB and EXP
> > files?
>
> You need to export something. If you're exporting classes, use the
> __declspec keyword as follows:
>
> class __declspec(dllexport) ExportedClass
> {
> // ...
> };
>
> This will cause all of the class's member functions and static members
> to be exported from the DLL. This will cause the linker to emit a .LIB
> file, which client applications can link to.
>
> --
> Tim Robinson (MVP, Windows SDK)
> http://mobius.sourceforge.net/
>



Relevant Pages

  • Re: [!! RANT !!] This is a hack at best (C4251)
    ... Micro$oft support for STL and standards in general is absolutely appaling. ... The built DLL exports the symbols, so I am not sure why the compiler issues the warnings. ... The function template is completely ignored and not even exported. ... I hope you can provide a fix as to how to get this to work (i.e. compile ...
    (microsoft.public.dotnet.languages.vc)
  • Re: disable reading of asp pages
    ... Don't put your CodeBehind class code in the Page template, ... compile it into a DLL. ... the Page Template will use the compiled DLL instead. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: umm... something... template(s)... something else... pointer(s)... and such... 0.o yah, Im hopel
    ... It doesn't make sense to try an put a template in a DLL, ... only instantiations of templates are object code. ... ahead of time (when you compile the DLL). ...
    (comp.lang.cpp)
  • Re: Protecting against type mismatch errors
    ... The VBA project in the template that I will be distributing with the DLL is ... Or they might know too much and try to use, say, an Excel ... the macros, with minor/major tweaking will work with Excel. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to distribute a template as a product
    ... I do have VB6 but I've never written a dll or a 'stub' for that matter so ... I've developed a Word template that I want to distribute as a product, ... vulnerable - there are tools about that will remove password protection from ... DLL where the source code is no longer present, and call the DLL from code ...
    (microsoft.public.word.vba.beginners)

Quantcast