c++.windows.32-bits - Export and Importing template classes in Dll
- Ingvaldur Sigurjonsson (94/94) Feb 19 2002 Hi
- Walter (11/53) Feb 19 2002 Try putting it into a .exe and see if that works. Also, do you really ne...
- Ingvaldur Sigurjonsson (86/155) Feb 20 2002 Hi again,
- Jan Knepper (18/142) Feb 20 2002 AFAIK:
- Ingvaldur Sigurjonsson (36/190) Feb 20 2002 Hi
- Christof Meerwald (15/17) Feb 20 2002 I guess you are just expecting too much from the compiler.
- Ingvaldur Sigurjonsson (30/47) Feb 20 2002 class
- Rajiv Bhagwat (10/66) Feb 20 2002 Whenever faced with similar problems, I try: -XD, which usually works. A...
- Walter (4/7) Feb 21 2002 It'd be useful to send customer email to Dinkumware requesting a DMC ver...
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 begin 666 tmpldll.hpp M(VEF("%D969I;F5D*%1-4$Q$3$Q?2%!0*0T*(V1E9FEN92!435!,1$Q,7TA0 M(" (" ("!V:7)T=6%L(&)O;VP 0F%S94UE=&AO9" I(#T ,#L- M"G1E;7!L871E(#P 8VQA<W, ='EP95]T(#X- M14, 5&UP;$1E<FEV960 .B!P=6)L:6, 0F%S90T*>PT*(" ('!U8FQI8SH- M"B (" (" 5&UP;$1E<FEV960H*3L-" T*(" (" ("!^5&UP;$1E<FEV M960H*3L-" T*(" (" ("!B;V]L($)A<V5-971H;V0H*3L-" T*(" (" M(" O+R!T>7!E7W0J(&]P97)A=&]R+3XH*2![(')E='5R;B F9%]D871A.R!] M" T*=&5M<&QA=&4 /"!C;&%S<R!T>7!E7W0 / T*:6YL:6YE(%1M<&Q$97)I M=F5D/'1Y<&5?=#XZ.E1M<&Q$97)I=F5D*"D-"GL-"B ("!M96US970H("9D M/CHZ?E1M<&Q$97)I=F5D*"D-"GL-"B (" Z.D]U='!U=$1E8G5G4W1R:6YG M87-E365T:&]D*"D-"GL-"B (" Z.D]U='!U=$1E8G5G4W1R:6YG*" B1&5R M;&5$97)I=F5D*"D-"B (" (" >PT*(" (" (" (" .CI/=71P=71$ M96)U9U-T<FEN9R (F,M=&]R(%-I;7!L941E<FEV961<;B( *3L-"B (" M=$1E8G5G4W1R:6YG*" B4VEM<&QE1&5R:79E9"!"87-E365T:&]D($EM<&QE ` end begin 666 tmpldll.cpp M+R\ 5&UP;$1L;"YC<' .B!$969I;F5S('1H92!E;G1R>2!P;VEN="!F;W( M62!$;&Q-86EN*"!(04Y$3$4 :$UO9'5L92P-"B (" (" (" (" (" M(" (" 1%=/4D0 ('5L7W)E87-O;E]F;W)?8V%L;"P-"B (" (" (" M(" (" (" (" 3%!63TE$(&QP4F5S97)V960-" D)"0D)("D-"GL-"B M7U!23T-%4U-?051404-(. T*"0EC87-E($1,3%]42%)%041?051404-(. T* &"GT-" T* ` end
Feb 19 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. sctmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN32_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 whenItry to instantiate a template class. See enclosed file tmpldll.hpp. scusedlltest.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, 1TmplDerivedTemplate 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 trytoinstantiate 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
Feb 19 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...builtHi I've built a dll that exports a bunch of template classes. A dll istmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3and a import library is generated. scwhen2_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 followsIusedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -otry to instantiate a template class. See enclosed file tmpldll.hpp. scD:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest).\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:try(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, 1TmplDerivedTemplate 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 Itoworkinstantiate 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 linesbegin 666 tmpldll.hpp M(VEF("%D969I;F5D*%1-4$Q$3$Q?2%!0*0T*(V1E9FEN92!435!,1$Q,7TA0 M4U!%0PT*(V5L<V4-"B-I9F1E9B!435!,1$Q,7T584$]25%,-"B-D969I;F4 M*"D /2 P.PT*?3L-" T*=&5M<&QA=&4 /"!C;&%S<R!T>7!E7W0 / T*8VQA M('L-"B (" (" (" (&UE;7-E=" )F1?9&%T82P ,' P+"!S:7IE;V8H M='EP95]T*2 I.PT*(" (" (" (" .CI/=71P=71$96)U9U-T<FEN9R M='!U=$1E8G5G4W1R:6YG*" B9"UT;W( 5&UP;$1E<FEV961<;B( *3L-"B M('L-"B (" (" (" (#HZ3W5T<'5T1&5B=6=3=')I;F<H(")4;7!L1&5R M="H ;W!E<F%T;W(M/B I('L <F5T=7)N("9D7V1A=&$[('T-" T*(" ('!R M('L-"B (" (" (" (#HZ3W5T<'5T1&5B=6=3=')I;F<H(")C+71O<B!3 M:6UP;&5$97)I=F5D*"D-"B (" (" >PT*(" (" (" (" .CI/=71P M=71$96)U9U-T<FEN9R (F0M=&]R(%-I;7!L941E<FEV961<;B( *3L-"B M(" >PT*(" (" (" (" .CI/=71P=71$96)U9U-T<FEN9R (E-I;7!L M941E<FEV960 0F%S94UE=&AO9"!);7!L96UE;G1E9%QN(B I.PT*(" (" 2("\J(%1-4$Q$3$Q?2%!0("HO ` end begin 666 contest.cpp M(VEN8VQU9&4 /'=I;F1O=W,N:#X-"B-I;F-L=61E(")T;7!L9&QL+FAP<"(- M" T*:6YT(&UA:6XH=F]I9"D-"GL-"B ("!4;7!L1&5R:79E9#QI;G0^(&0[ ` endok. 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
Feb 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! #else #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...builtHi I've built a dll that exports a bunch of template classes. A dll istmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3and a import library is generated. scwhen2_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 followsIusedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -otry to instantiate a template class. See enclosed file tmpldll.hpp. scD:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest).\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:try(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, 1TmplDerivedTemplate 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 Itoworkinstantiate 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 linesName: 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-uuencodeok. 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
Feb 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! #else #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.DLLThis makes ClassName: __declspec(dllimport) ClassName when compiling the.EXEHTH Jan Ingvaldur Sigurjonsson wrote:app.Hi again, It work's as expected when I include the tmpldll.hpp directly into thetestYou 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 acontest.cpp -mn -C -WA -S -3 -a8 -c -gf -DJUST_APP -D_CONSOLE=1 -ocontest.obWindows app and a Console based app). options being used are default when project is created in the IDDE. sc/A:512j link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:mainCRTStartup /BAS:4194304successfully.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 completesneedShould 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 reallytoall those options <g>? When diagnosing such problems, it helps a lotbeeliminate as many switches and complications as possible. Problems cantmpldll.cpp -Ae -Ar -mn -C -WD -Pz -S -5 -a8 -c -gf -DTMPLDLL_EXPORTS -DWIN3obfuscated by layers of macros, directories, include files, etc. "Ingvaldur Sigurjonsson" <ingi ementor.se> wrote in message news:a4usbo$8s6$1 digitaldaemon.com...builtHi I've built a dll that exports a bunch of template classes. A dll isand a import library is generated. scusedlltest.cpp -mn -C -WA -S -ND -3 -a8 -c -gf -D_MT -D_DEBUG -I\utv\vwcl -owhen2_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 followsItry to instantiate a template class. See enclosed file tmpldll.hpp. sc/BAS:4194304.\usedlltest_objs\usedlltest.obj <... some other files in my testapp project ... > link /CO /NOI /DE /NOPACKF /XN /NT /ENTRY:WinMainCRTStartupcreate aD:\utv\dm\test\wintest\.\usedlltest_objs\usedlltest.OBJ(usedlltest)/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:(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, 1TmplDerivedTemplate class and 1 SimpleDerived class. I also enclose the usedlltest.cpp containing the LibMain ! JustIWindows DLL project with these files and try it for you self. When instantiating the classes in my testapp, I get link error whenthetrytoinstantiate TmplDerived class, but it works fine when I instantiateerrorSimpleDerived class. TmplDerived<int> d; <-- This gives me link-time(application/x-unknown-content-type-hppfile)work// d.BaseMethod(); SimpleDerived s; <-- Just using these 2 linesName: tmpldll.hpp tmpldll.hpp Type: HPP fileok. 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(application/x-unknown-content-type-cppfile)Encoding: x-uuencode Name: contest.cpp contest.cpp Type: MEW32 Fileregards - IngvaldurEncoding: x-uuencode
Feb 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?
Feb 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:classit doesn't seem to get exported by the generated dll while the simpleinstantiationsdoes.I guess you are just expecting too much from the compiler. When compiling the DLL the compiler can't know which templatemight be needed, so it doesn't generate any template instantiations. TheC++standard provides a feature called "explicit template instantiation" totellthe 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 thetemplate. 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 - Ingvaldurbye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Feb 20 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...dll's,On Wed, 20 Feb 2002 17:16:36 +0100, Ingvaldur Sigurjonsson wrote:classit doesn't seem to get exported by the generated dll while the simpleinstantiationsdoes.I guess you are just expecting too much from the compiler. When compiling the DLL the compiler can't know which templatemight be needed, so it doesn't generate any template instantiations. TheC++standard provides a feature called "explicit template instantiation" totellthe 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 thetemplate. 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 asso 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 soandit was quite convenient :-) I think I read som article/kb-article about this as well but I cant findthereference 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 tobuildDinkumware's STL from it but it choked on things which seemed to rely on Microsoft extensions and templates ). Thank you for your answer. regards - Ingvaldurbye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Feb 20 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.
Feb 21 2002