Template Libraries

From: nifsmith (hawklord451_at_lycos.co.uk)
Date: 02/06/05


Date: Sun, 6 Feb 2005 10:48:53 +0000 (UTC)


Hi

I am trying to create a library of stacks, lists templates in a DLL. I
am getting a linker error when trying to tie in my library to another
project.

Having posted earlier and read the faq on templates i had been including
a seperate template.cpp file when compiling my templates files in with a
project. However now that I have created a DLL file from my templates I
was getting a link error message.

I therefore revisited the faq and instead of declaring and defining my
templates in seperate files, i put both into the header files for the
seperate templates. This seemed a bit odd to me as now I am left with a
DLL which has a number of .cpp files which only have include header file
statements in them as all the code is now in the header files.

I compile my DLL (using MS instructions I am using VS 2003). To
simplify testing I am copying both the DLL and header files into an
"includes" folder within my project. I build the project and hey presto
no linker errors.

However I have a nagging doubt that I am leading myself up the garden
path and have a question.

I am copying the DLL and its header files into the includes folder. Is
this correct, if so is the inclusion of the DLL not a moot point. As the
header files are filled with both the definitions and declarations isn't
the DLL redundant. Include the header file and won't all the code from
the header file be included at that point. I am a bit of a newbie in C++
so this is a bit of an assumption by me.

To make sure that I am creating the library in the right way could
anyone point me to a source of info on this topic.

TYIA

nifsmith



Relevant Pages

  • Re: Problem with reading an int with operator>>
    ... implemented in header files, is compiled into MSVCP60.DLL. ... Because it makes it impossible to patch std::string without rebuilding MSVCP60.DLL (if you use static linking). ... At the time the decision was made to include string in the DLL, it obviously wasn't known that it either had any bugs in or that there would be a problem with patching the DLL in an SP, which is obviously the normal way that library bugs are handled. ... I believe this allows MS to fix the CRT DLLs using Windows Update ...
    (microsoft.public.vc.stl)
  • Re: Basic C++ question
    ... class ClassInDll { ... DLL program: ... main CPP program ... So I Copied the whole cpp and corresponding header files in to ...
    (microsoft.public.vc.mfc)
  • accessing DLL headers
    ... software ie functions, headers, libs and put them in a dll. ... need to use in the main exe. ... I should also mention that the generic functions that I am calling to ... if I do that then why not just rename the header files and include them ...
    (microsoft.public.dotnet.languages.vc)
  • Accessing header files from DLL
    ... functions, headers, libs and put them in a dll. ... need to use in the main exe. ... I should also mention that the generic functions that I am calling to ... if I do that then why not just rename the header files and include them ...
    (microsoft.public.vc.language)
  • Re: msvcp90d.dll and msvcr90d.dll
    ... STL is built with source code ... You don't _need_ the DLL. ... Standrad C++ library consists mostly, but not entirely, of templates. ...
    (microsoft.public.vc.language)