Thread overview
Export and Importing template classes in Dll
Feb 20, 2002
Walter
Feb 20, 2002
Jan Knepper
Feb 20, 2002
Christof Meerwald
Feb 21, 2002
Rajiv Bhagwat
Feb 21, 2002
Walter
February 20, 2002
Hi

I've built a dll that exports a bunch of template classes. A dll is built and a import library is generated.

sc
tmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3
2_LEAN_AND_MEAN -otmpldll.obj
link /CO /NOI /DO /DE /NOPACKF /XN /NT /ENTRY:_DllMainCRTStartup
/BAS:268435456 /A:512 /IMPL:.\$SCW$.LIB @tmpldll.LNK
ren .\$SCW$.DLL tmpldll.DLL
ren .\$SCW$.LIB tmpldll.LIB
.\tmpldll.DLL built

When linking with the import library the linker complains as follows when I try to instantiate a template class. See enclosed file tmpldll.hpp.

sc
usedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -o
.\usedlltest_objs\usedlltest.obj
<... some other files in my testapp project ... >
link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:WinMainCRTStartup /BAS:4194304
/A:512 /RC   :.\usedlltest_objs\usedlltest.RES @usedlltest.LNK
Error: D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
(1464936): Symbol Undefined ??1?$TmplDerived@H@@QAE@XZ (syscall
TmplDerived<int >::~TmplDerived<int >(void ))
Error: D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
(1464936): Symbol Undefined ??0?$TmplDerived@H@@QAE@XZ (syscall
TmplDerived<int >::TmplDerived<int >(void ))
Lines Processed: 1133565  Errors: 2  Warnings: 0
Build failed

I enclose a sample tmpldll.hpp file containing  1 Base class, 1 TmplDerived
Template class and 1 SimpleDerived class.
I also enclose the usedlltest.cpp containing the LibMain ! Just create a
Windows DLL project with these files and try it for you self.

When instantiating the classes in my testapp, I get link error when I try to instantiate TmplDerived class, but it works fine when I instantiate the SimpleDerived class.

                TmplDerived<int> d;    <-- This gives me link-time error
                // d.BaseMethod();

                SimpleDerived s;        <-- Just using these 2 lines work
ok.
                s.BaseMethod();

Can anyone please advise ?

I can and I have built this example in Micrsoft Visual C++ 6.0.

I got my Digital Mars C++ CD today :-)

Regards
- Ingvaldur





February 20, 2002
Try putting it into a .exe and see if that works. Also, do you really need all those options <g>? When diagnosing such problems, it helps a lot to eliminate as many switches and complications as possible. Problems can be obfuscated by layers of macros, directories, include files, etc.

"Ingvaldur Sigurjonsson" <ingi@ementor.se> wrote in message news:a4usbo$8s6$1@digitaldaemon.com...
> Hi
>
> I've built a dll that exports a bunch of template classes. A dll is built and a import library is generated.
>
> sc
>
tmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3
> 2_LEAN_AND_MEAN -otmpldll.obj
> link /CO /NOI /DO /DE /NOPACKF /XN /NT /ENTRY:_DllMainCRTStartup
> /BAS:268435456 /A:512 /IMPL:.\$SCW$.LIB @tmpldll.LNK
> ren .\$SCW$.DLL tmpldll.DLL
> ren .\$SCW$.LIB tmpldll.LIB
> .\tmpldll.DLL built
>
> When linking with the import library the linker complains as follows when
I
> try to instantiate a template class. See enclosed file tmpldll.hpp.
>
> sc
>
usedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -o
> .\usedlltest_objs\usedlltest.obj
> <... some other files in my testapp project ... >
> link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:WinMainCRTStartup /BAS:4194304
> /A:512 /RC   :.\usedlltest_objs\usedlltest.RES @usedlltest.LNK
> Error: D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> (1464936): Symbol Undefined ??1?$TmplDerived@H@@QAE@XZ (syscall
> TmplDerived<int >::~TmplDerived<int >(void ))
> Error: D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> (1464936): Symbol Undefined ??0?$TmplDerived@H@@QAE@XZ (syscall
> TmplDerived<int >::TmplDerived<int >(void ))
> Lines Processed: 1133565  Errors: 2  Warnings: 0
> Build failed
>
> I enclose a sample tmpldll.hpp file containing  1 Base class, 1
TmplDerived
> Template class and 1 SimpleDerived class.
> I also enclose the usedlltest.cpp containing the LibMain ! Just create a
> Windows DLL project with these files and try it for you self.
>
> When instantiating the classes in my testapp, I get link error when I try
to
> instantiate TmplDerived class, but it works fine when I instantiate the SimpleDerived class.
>
>                 TmplDerived<int> d;    <-- This gives me link-time error
>                 // d.BaseMethod();
>
>                 SimpleDerived s;        <-- Just using these 2 lines work
> ok.
>                 s.BaseMethod();
>
> Can anyone please advise ?
>
> I can and I have built this example in Micrsoft Visual C++ 6.0.
>
> I got my Digital Mars C++ CD today :-)
>
> Regards
> - Ingvaldur
>
>
>
>


February 20, 2002
Hi again,

It work's as expected when I include the tmpldll.hpp directly into the app. You can make it work in your own testapplication if you do one of the following

i) I just have to define the symbol TMPLDLL_EXPORTS for the test
application. That defines the __declspec(dllexport) for the classes.
ii) use the updated tmpldll.hpp which I enclose and define the symbol
JUST_APP for the test application. By doing that you'll have neither
__declspec(dllimport) or __declspec(dllexport) for the classes.

This the output for when I build my test application (I've built both a test Windows app and a Console based app).

options being used are default when project is created in the IDDE.

sc
contest.cpp -mn -C -WA -S -3 -a8 -c -gf -DJUST_APP -D_CONSOLE=1 -ocontest.ob
j
link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:mainCRTStartup /BAS:4194304 /A:512
@contest.LNK
ren .\$SCW$.EXE contest.EXE
.\contest.EXE built
Lines Processed: 124544  Errors: 0  Warnings: 0
Successful build

I tried to dump the exports from the .exe by entering dumpexe
contest.exe -e, but the dumpexe exited with error:
... lot of output ...
    ---- seg 1
00: 6961 (26977)     Seg, segment index for this table
02: 486e (18542)     cPair, number of source line pairs to follow
Error: file contest.exe is too short (34796/4)

When building the contest.cpp from the command line with
sc -mn -DJUST_APP contest.cpp
contest.exe gets built and dumpexe contest.exe -e completes successfully.

Should I try to build the .dll with fewer switches maybe ?

Regards
- Ingi

"Walter" <walter@digitalmars.com> wrote in message news:a4vie5$jgl$2@digitaldaemon.com...
> Try putting it into a .exe and see if that works. Also, do you really need all those options <g>? When diagnosing such problems, it helps a lot to eliminate as many switches and complications as possible. Problems can be obfuscated by layers of macros, directories, include files, etc.
>
> "Ingvaldur Sigurjonsson" <ingi@ementor.se> wrote in message news:a4usbo$8s6$1@digitaldaemon.com...
> > Hi
> >
> > I've built a dll that exports a bunch of template classes. A dll is
built
> > and a import library is generated.
> >
> > sc
> >
>
tmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3
> > 2_LEAN_AND_MEAN -otmpldll.obj
> > link /CO /NOI /DO /DE /NOPACKF /XN /NT /ENTRY:_DllMainCRTStartup
> > /BAS:268435456 /A:512 /IMPL:.\$SCW$.LIB @tmpldll.LNK
> > ren .\$SCW$.DLL tmpldll.DLL
> > ren .\$SCW$.LIB tmpldll.LIB
> > .\tmpldll.DLL built
> >
> > When linking with the import library the linker complains as follows
when
> I
> > try to instantiate a template class. See enclosed file tmpldll.hpp.
> >
> > sc
> >
>
usedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -o
> > .\usedlltest_objs\usedlltest.obj
> > <... some other files in my testapp project ... >
> > link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:WinMainCRTStartup /BAS:4194304
> > /A:512 /RC   :.\usedlltest_objs\usedlltest.RES @usedlltest.LNK
> > Error:
D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> > (1464936): Symbol Undefined ??1?$TmplDerived@H@@QAE@XZ (syscall
> > TmplDerived<int >::~TmplDerived<int >(void ))
> > Error:
D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> > (1464936): Symbol Undefined ??0?$TmplDerived@H@@QAE@XZ (syscall
> > TmplDerived<int >::TmplDerived<int >(void ))
> > Lines Processed: 1133565  Errors: 2  Warnings: 0
> > Build failed
> >
> > I enclose a sample tmpldll.hpp file containing  1 Base class, 1
> TmplDerived
> > Template class and 1 SimpleDerived class.
> > I also enclose the usedlltest.cpp containing the LibMain ! Just create a
> > Windows DLL project with these files and try it for you self.
> >
> > When instantiating the classes in my testapp, I get link error when I
try
> to
> > instantiate TmplDerived class, but it works fine when I instantiate the SimpleDerived class.
> >
> >                 TmplDerived<int> d;    <-- This gives me link-time error
> >                 // d.BaseMethod();
> >
> >                 SimpleDerived s;        <-- Just using these 2 lines
work
> > ok.
> >                 s.BaseMethod();
> >
> > Can anyone please advise ?
> >
> > I can and I have built this example in Micrsoft Visual C++ 6.0.
> >
> > I got my Digital Mars C++ CD today :-)
> >
> > Regards
> > - Ingvaldur
> >
> >
> >
> >
>
>




February 20, 2002
AFAIK:

Build the .DLL with -WD
Build the .EXE that uses the .DLL with -WA
Make sure you have a define like:

class header file:

#ifdef _WINDLL                // -WD throws this!
#   define CLASS_MOD    __declspec(dllexport)
#else
#   define CLASS_MOD    __declspec(dllimport)
#endif


class CLASS_MOD ClassName
{
};



This makes ClassName: __declspec(dllexport) ClassName when compiling the .DLL
This makes ClassName: __declspec(dllimport) ClassName when compiling the .EXE

HTH

Jan



Ingvaldur Sigurjonsson wrote:

> Hi again,
>
> It work's as expected when I include the tmpldll.hpp directly into the app. You can make it work in your own testapplication if you do one of the following
>
> i) I just have to define the symbol TMPLDLL_EXPORTS for the test
> application. That defines the __declspec(dllexport) for the classes.
> ii) use the updated tmpldll.hpp which I enclose and define the symbol
> JUST_APP for the test application. By doing that you'll have neither
> __declspec(dllimport) or __declspec(dllexport) for the classes.
>
> This the output for when I build my test application (I've built both a test Windows app and a Console based app).
>
> options being used are default when project is created in the IDDE.
>
> sc
> contest.cpp -mn -C -WA -S -3 -a8 -c -gf -DJUST_APP -D_CONSOLE=1 -ocontest.ob
> j
> link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:mainCRTStartup /BAS:4194304 /A:512
> @contest.LNK
> ren .\$SCW$.EXE contest.EXE
> .\contest.EXE built
> Lines Processed: 124544  Errors: 0  Warnings: 0
> Successful build
>
> I tried to dump the exports from the .exe by entering dumpexe
> contest.exe -e, but the dumpexe exited with error:
> ... lot of output ...
>     ---- seg 1
> 00: 6961 (26977)     Seg, segment index for this table
> 02: 486e (18542)     cPair, number of source line pairs to follow
> Error: file contest.exe is too short (34796/4)
>
> When building the contest.cpp from the command line with
> sc -mn -DJUST_APP contest.cpp
> contest.exe gets built and dumpexe contest.exe -e completes successfully.
>
> Should I try to build the .dll with fewer switches maybe ?
>
> Regards
> - Ingi
>
> "Walter" <walter@digitalmars.com> wrote in message news:a4vie5$jgl$2@digitaldaemon.com...
> > Try putting it into a .exe and see if that works. Also, do you really need all those options <g>? When diagnosing such problems, it helps a lot to eliminate as many switches and complications as possible. Problems can be obfuscated by layers of macros, directories, include files, etc.
> >
> > "Ingvaldur Sigurjonsson" <ingi@ementor.se> wrote in message news:a4usbo$8s6$1@digitaldaemon.com...
> > > Hi
> > >
> > > I've built a dll that exports a bunch of template classes. A dll is
> built
> > > and a import library is generated.
> > >
> > > sc
> > >
> >
> tmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3
> > > 2_LEAN_AND_MEAN -otmpldll.obj
> > > link /CO /NOI /DO /DE /NOPACKF /XN /NT /ENTRY:_DllMainCRTStartup
> > > /BAS:268435456 /A:512 /IMPL:.\$SCW$.LIB @tmpldll.LNK
> > > ren .\$SCW$.DLL tmpldll.DLL
> > > ren .\$SCW$.LIB tmpldll.LIB
> > > .\tmpldll.DLL built
> > >
> > > When linking with the import library the linker complains as follows
> when
> > I
> > > try to instantiate a template class. See enclosed file tmpldll.hpp.
> > >
> > > sc
> > >
> >
> usedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -o
> > > .\usedlltest_objs\usedlltest.obj
> > > <... some other files in my testapp project ... >
> > > link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:WinMainCRTStartup /BAS:4194304
> > > /A:512 /RC   :.\usedlltest_objs\usedlltest.RES @usedlltest.LNK
> > > Error:
> D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> > > (1464936): Symbol Undefined ??1?$TmplDerived@H@@QAE@XZ (syscall
> > > TmplDerived<int >::~TmplDerived<int >(void ))
> > > Error:
> D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> > > (1464936): Symbol Undefined ??0?$TmplDerived@H@@QAE@XZ (syscall
> > > TmplDerived<int >::TmplDerived<int >(void ))
> > > Lines Processed: 1133565  Errors: 2  Warnings: 0
> > > Build failed
> > >
> > > I enclose a sample tmpldll.hpp file containing  1 Base class, 1
> > TmplDerived
> > > Template class and 1 SimpleDerived class.
> > > I also enclose the usedlltest.cpp containing the LibMain ! Just create a
> > > Windows DLL project with these files and try it for you self.
> > >
> > > When instantiating the classes in my testapp, I get link error when I
> try
> > to
> > > instantiate TmplDerived class, but it works fine when I instantiate the SimpleDerived class.
> > >
> > >                 TmplDerived<int> d;    <-- This gives me link-time error
> > >                 // d.BaseMethod();
> > >
> > >                 SimpleDerived s;        <-- Just using these 2 lines
> work
> > > ok.
> > >                 s.BaseMethod();
> > >
> > > Can anyone please advise ?
> > >
> > > I can and I have built this example in Micrsoft Visual C++ 6.0.
> > >
> > > I got my Digital Mars C++ CD today :-)
> > >
> > > Regards
> > > - Ingvaldur
> > >
> > >
> > >
> > >
> >
> >
>
>                   Name: tmpldll.hpp
>    tmpldll.hpp    Type: HPP file (application/x-unknown-content-type-hppfile)
>               Encoding: x-uuencode
>
>                   Name: contest.cpp
>    contest.cpp    Type: MEW32 File (application/x-unknown-content-type-cppfile)
>               Encoding: x-uuencode

February 20, 2002
Hi

I have been doing what you've explained below and it works for classes that are NOT templates, but it doesn't work for template classes

"Jan Knepper" <jan@smartsoft.cc> wrote in message news:3C73AAA9.5E87B42D@smartsoft.cc...
> AFAIK:
>
> Build the .DLL with -WD
> Build the .EXE that uses the .DLL with -WA
> Make sure you have a define like:
>
> class header file:
>
> #ifdef _WINDLL                // -WD throws this!
> #   define CLASS_MOD    __declspec(dllexport)
> #else
> #   define CLASS_MOD    __declspec(dllimport)
> #endif
>
>
> class CLASS_MOD ClassName
> {
> };
This works ok.

But if I add a class:
class CLASS_MOD TmplClassName
{
};

it doesn't seem to get exported by the generated dll while the simple class does.

Please see the latest tmpldef.hpp in this thread for reference/example.

The workaround for this solution was to include the source of the dll (except the LibMain) into my application and that works ok.

>
>
>
> This makes ClassName: __declspec(dllexport) ClassName when compiling the
.DLL
> This makes ClassName: __declspec(dllimport) ClassName when compiling the
.EXE
>
> HTH
>
> Jan
>
>
>
> Ingvaldur Sigurjonsson wrote:
>
> > Hi again,
> >
> > It work's as expected when I include the tmpldll.hpp directly into the
app.
> > You can make it work in your own testapplication if you do one of the following
> >
> > i) I just have to define the symbol TMPLDLL_EXPORTS for the test
> > application. That defines the __declspec(dllexport) for the classes.
> > ii) use the updated tmpldll.hpp which I enclose and define the symbol
> > JUST_APP for the test application. By doing that you'll have neither
> > __declspec(dllimport) or __declspec(dllexport) for the classes.
> >
> > This the output for when I build my test application (I've built both a
test
> > Windows app and a Console based app).
> >
> > options being used are default when project is created in the IDDE.
> >
> > sc
> >
contest.cpp -mn -C -WA -S -3 -a8 -c -gf -DJUST_APP -D_CONSOLE=1 -ocontest.ob
> > j
> > link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:mainCRTStartup /BAS:4194304
/A:512
> > @contest.LNK
> > ren .\$SCW$.EXE contest.EXE
> > .\contest.EXE built
> > Lines Processed: 124544  Errors: 0  Warnings: 0
> > Successful build
> >
> > I tried to dump the exports from the .exe by entering dumpexe
> > contest.exe -e, but the dumpexe exited with error:
> > ... lot of output ...
> >     ---- seg 1
> > 00: 6961 (26977)     Seg, segment index for this table
> > 02: 486e (18542)     cPair, number of source line pairs to follow
> > Error: file contest.exe is too short (34796/4)
> >
> > When building the contest.cpp from the command line with
> > sc -mn -DJUST_APP contest.cpp
> > contest.exe gets built and dumpexe contest.exe -e completes
successfully.
> >
> > Should I try to build the .dll with fewer switches maybe ?
> >
> > Regards
> > - Ingi
> >
> > "Walter" <walter@digitalmars.com> wrote in message news:a4vie5$jgl$2@digitaldaemon.com...
> > > Try putting it into a .exe and see if that works. Also, do you really
need
> > > all those options <g>? When diagnosing such problems, it helps a lot
to
> > > eliminate as many switches and complications as possible. Problems can
be
> > > obfuscated by layers of macros, directories, include files, etc.
> > >
> > > "Ingvaldur Sigurjonsson" <ingi@ementor.se> wrote in message news:a4usbo$8s6$1@digitaldaemon.com...
> > > > Hi
> > > >
> > > > I've built a dll that exports a bunch of template classes. A dll is
> > built
> > > > and a import library is generated.
> > > >
> > > > sc
> > > >
> > >
> >
tmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3
> > > > 2_LEAN_AND_MEAN -otmpldll.obj
> > > > link /CO /NOI /DO /DE /NOPACKF /XN /NT /ENTRY:_DllMainCRTStartup
> > > > /BAS:268435456 /A:512 /IMPL:.\$SCW$.LIB @tmpldll.LNK
> > > > ren .\$SCW$.DLL tmpldll.DLL
> > > > ren .\$SCW$.LIB tmpldll.LIB
> > > > .\tmpldll.DLL built
> > > >
> > > > When linking with the import library the linker complains as follows
> > when
> > > I
> > > > try to instantiate a template class. See enclosed file tmpldll.hpp.
> > > >
> > > > sc
> > > >
> > >
> >
usedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -o
> > > > .\usedlltest_objs\usedlltest.obj
> > > > <... some other files in my testapp project ... >
> > > > link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:WinMainCRTStartup
/BAS:4194304
> > > > /A:512 /RC   :.\usedlltest_objs\usedlltest.RES @usedlltest.LNK Error:
> > D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> > > > (1464936): Symbol Undefined ??1?$TmplDerived@H@@QAE@XZ (syscall
> > > > TmplDerived<int >::~TmplDerived<int >(void ))
> > > > Error:
> > D:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)
> > > > (1464936): Symbol Undefined ??0?$TmplDerived@H@@QAE@XZ (syscall
> > > > TmplDerived<int >::TmplDerived<int >(void ))
> > > > Lines Processed: 1133565  Errors: 2  Warnings: 0
> > > > Build failed
> > > >
> > > > I enclose a sample tmpldll.hpp file containing  1 Base class, 1
> > > TmplDerived
> > > > Template class and 1 SimpleDerived class.
> > > > I also enclose the usedlltest.cpp containing the LibMain ! Just
create a
> > > > Windows DLL project with these files and try it for you self.
> > > >
> > > > When instantiating the classes in my testapp, I get link error when
I
> > try
> > > to
> > > > instantiate TmplDerived class, but it works fine when I instantiate
the
> > > > SimpleDerived class.
> > > >
> > > >                 TmplDerived<int> d;    <-- This gives me link-time
error
> > > >                 // d.BaseMethod();
> > > >
> > > >                 SimpleDerived s;        <-- Just using these 2 lines
> > work
> > > > ok.
> > > >                 s.BaseMethod();
> > > >
> > > > Can anyone please advise ?
> > > >
> > > > I can and I have built this example in Micrsoft Visual C++ 6.0.
> > > >
> > > > I got my Digital Mars C++ CD today :-)
> > > >
> > > > Regards
> > > > - Ingvaldur
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >                   Name: tmpldll.hpp
> >    tmpldll.hpp    Type: HPP file
(application/x-unknown-content-type-hppfile)
> >               Encoding: x-uuencode
> >
> >                   Name: contest.cpp
> >    contest.cpp    Type: MEW32 File
(application/x-unknown-content-type-cppfile)
> >               Encoding: x-uuencode
>

regards
- Ingvaldur


February 20, 2002
On Wed, 20 Feb 2002 17:16:36 +0100, Ingvaldur Sigurjonsson wrote:
> it doesn't seem to get exported by the generated dll while the simple class does.

I guess you are just expecting too much from the compiler.

When compiling the DLL the compiler can't know which template instantiations might be needed, so it doesn't generate any template instantiations. The C++ standard provides a feature called "explicit template instantiation" to tell the compiler which templates to instantiate, but AFAIK, DMC++ doesn't support it yet.

And there is also a "template export" feature in the C++ standard, but currently no compiler (including DMC++) supports this one.


I am wondering how you got Microsoft Visual C++ to instantiate the template.


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

...and what have you contributed to the Net?
February 20, 2002
"Christof Meerwald" <cmeerw@web.de> wrote in message news:a50oor$16p3$1@digitaldaemon.com...
> On Wed, 20 Feb 2002 17:16:36 +0100, Ingvaldur Sigurjonsson wrote:
> > it doesn't seem to get exported by the generated dll while the simple
class
> > does.
>
> I guess you are just expecting too much from the compiler.
>
> When compiling the DLL the compiler can't know which template
instantiations
> might be needed, so it doesn't generate any template instantiations. The
C++
> standard provides a feature called "explicit template instantiation" to
tell
> the compiler which templates to instantiate, but AFAIK, DMC++ doesn't support it yet.
>
> And there is also a "template export" feature in the C++ standard, but currently no compiler (including DMC++) supports this one.
>
>
> I am wondering how you got Microsoft Visual C++ to instantiate the
template.

Well I started wondering about it as well, I agree with you'r reasoning above.

The reason why I believed it was possible was because I've been using both
STLport v4.5.x and Dinkumware STL which both can be built and used as dll's,
so why shouldn't I be able too.
I guess that Microsoft is probably using some non-standard way of
accomplishing this, dont blame them for that, because they usually do so and
it was quite convenient :-)

I think I read som article/kb-article about this as well but I cant find the reference right now.

There was an easy workaround for this problem so I wont shed tears not having this functionality in DMC++.

But I would like to be able to use the STLport v.4.5.x. That would make it easier for me to write reusable classes that I can use on both Win32 and Linux/Solaris and OpenVMS without bloating the code with #ifdefs....

I'm happily unknowing about the inners of the parser/compiler and how it act's on template stuff so I just hope that Walter find's time to enhance the template stuff required to for the new STLport. ( I also tried to build Dinkumware's STL from it but it choked on things which seemed to rely on Microsoft extensions and templates ).

Thank you for your answer.

regards
- Ingvaldur

>
>
> bye, Christof
>
> --
> http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
>
> ...and what have you contributed to the Net?


February 21, 2002
Whenever faced with similar problems, I try: -XD, which usually works. As per documentation, you can also try to instantiate individual classes using -XItemp<type>

- Rajiv

"Ingvaldur Sigurjonsson" <ingi@ementor.se> wrote in message news:a517h2$1d9n$1@digitaldaemon.com...
>
> "Christof Meerwald" <cmeerw@web.de> wrote in message news:a50oor$16p3$1@digitaldaemon.com...
> > On Wed, 20 Feb 2002 17:16:36 +0100, Ingvaldur Sigurjonsson wrote:
> > > it doesn't seem to get exported by the generated dll while the simple
> class
> > > does.
> >
> > I guess you are just expecting too much from the compiler.
> >
> > When compiling the DLL the compiler can't know which template
> instantiations
> > might be needed, so it doesn't generate any template instantiations. The
> C++
> > standard provides a feature called "explicit template instantiation" to
> tell
> > the compiler which templates to instantiate, but AFAIK, DMC++ doesn't support it yet.
> >
> > And there is also a "template export" feature in the C++ standard, but currently no compiler (including DMC++) supports this one.
> >
> >
> > I am wondering how you got Microsoft Visual C++ to instantiate the
> template.
>
> Well I started wondering about it as well, I agree with you'r reasoning above.
>
> The reason why I believed it was possible was because I've been using both STLport v4.5.x and Dinkumware STL which both can be built and used as
dll's,
> so why shouldn't I be able too.
> I guess that Microsoft is probably using some non-standard way of
> accomplishing this, dont blame them for that, because they usually do so
and
> it was quite convenient :-)
>
> I think I read som article/kb-article about this as well but I cant find
the
> reference right now.
>
> There was an easy workaround for this problem so I wont shed tears not having this functionality in DMC++.
>
> But I would like to be able to use the STLport v.4.5.x. That would make it easier for me to write reusable classes that I can use on both Win32 and Linux/Solaris and OpenVMS without bloating the code with #ifdefs....
>
> I'm happily unknowing about the inners of the parser/compiler and how it act's on template stuff so I just hope that Walter find's time to enhance the template stuff required to for the new STLport. ( I also tried to
build
> Dinkumware's STL from it but it choked on things which seemed to rely on Microsoft extensions and templates ).
>
> Thank you for your answer.
>
> regards
> - Ingvaldur
>
> >
> >
> > bye, Christof
> >
> > --
> > http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
> >
> > ...and what have you contributed to the Net?
>
>


February 21, 2002
"Ingvaldur Sigurjonsson" <ingi@ementor.se> wrote in message news:a517h2$1d9n$1@digitaldaemon.com...
> ( I also tried to build
> Dinkumware's STL from it but it choked on things which seemed to rely on
> Microsoft extensions and templates ).

It'd be useful to send customer email to Dinkumware requesting a DMC version of their great library.