From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: Library with templates - help !!!!!!!!!!!!! Date: Sat, 20 Jan 2001 14:49:05 +0000 Organization: Customer of Energis Squared Lines: 44 Message-ID: References: <94c3au$791$1 AT info DOT cyf-kr DOT edu DOT pl> NNTP-Posting-Host: modem-45.elmiron.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: newsg1.svr.pol.co.uk 980002156 26905 62.136.92.45 (20 Jan 2001 14:49:16 GMT) NNTP-Posting-Date: 20 Jan 2001 14:49:16 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Rafal Maj" wrote: > Hi, > I have problem when I compile program using library with templates. > Project file contains bugmain.cc & bug.cc. In this example, bugmain.cc is my > mian program, bug.cc is my library & bug.h is library header. I have > problems to build my program when I'm using templates in my library. > I get error report : > Error: bugmain.o: In function `main': > bugmain.cc(2) Error: undefined reference to `box::move(int)' > I know, that there are options like -frepo, no-implict-templates, etc... but > I realy don't know how to set them to make my exaple work. You don't need to worry about those options for this particular problem, it's not DJGPP specific. > If You can help me, please write exacly what should be compiler & linker > options, and what I have to change inside my source files. ok, below is rearranged how it should be, note that bug.cc no longer exists: > ================== BUGMAIN.CC ================= > #include "bug.h" int main() { /* <-- main returns an int */ > box b; > b.move(5); > } > ================== BUG.H =============== > template > class box { > public : > typ x,y; > void move(typ d); > }; > template void box::move(typ d) { > x+=d; y+=d; > } > ========================================================= compile with: gpp -O2 -Wall -W bugmain.cc -o bugmain