From: "Rafal Maj" Newsgroups: comp.os.msdos.djgpp Subject: Templates in library - continue Date: Sat, 20 Jan 2001 20:00:40 +0100 Organization: Academic Computer Center CYFRONET AGH Lines: 52 Message-ID: <94cn50$a4r$2@info.cyf-kr.edu.pl> NNTP-Posting-Host: d-94-53-12.cyfronet.krakow.pl Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8bit X-Trace: info.cyf-kr.edu.pl 980017120 10395 149.156.1.172 (20 Jan 2001 18:58:40 GMT) X-Complaints-To: news AT cyf-kr DOT edu DOT pl NNTP-Posting-Date: 20 Jan 2001 18:58:40 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Sorry, maybe I don't understand way of writing C++ libraries... but I think this is correct : In file lib.h I write : class cBox { public : void move(); } In lib.cc : void cBox::move() { /* ..............very long algoritm............ / } In main.cc : #include "lib.h" main() { cBox obj; obj.move(); } In project file : - add "main.c" - add "lib.cc" Now everything is correct, when I'm doing change in main.cc only main.cc is re-compiling, same fore lib.cc -------------------- But when I want "cBox" to ba template class : lib.h : template class cBox { public : void move(); } lib.cc : template void cBox::move() { /* ..............very long algoritm............ */ } main.c : #include "lib.h" main() { cBox obj; obj.move(); } I get error while building (not when compiling) : Compiling: main.cc no errors Creating: main.exe Error: main.o: In function `main': main.cc(2) Error: undefined reference to `box::move()' There were some errors When I copy-paste source of lib.cc / lib.h into main.cc everything is O.K., but any small change to main() function makes class cBox recompile and vice-versa. In my program, when it is divided to several files it compile + build after changing one library in about 5sec, when this program was in one file it took about 20s to re-compile after every change. I read in Rhide help about CXX compile flags, that some flags (like -frepo, falt-external-templates, -fno-implicit-templates) are needed for such programs (or maybe I didn't understand docs... my english is bad). When I simply select compile option -frepo it didn't help. So what compile/link flags I should use to make this library (.cc + .h) work while using template classes in it ??? Please help... Thanks in advice, Rafał