delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/20/08:51:34

From: "Rafal Maj" <maj_rafal AT poczta DOT onet DOT pl>
Newsgroups: comp.os.msdos.djgpp
Subject: Library with templates - help !!!!!!!!!!!!!
Date: Sat, 20 Jan 2001 14:21:24 +0100
Organization: Academic Computer Center CYFRONET AGH
Lines: 60
Message-ID: <94c3au$791$1@info.cyf-kr.edu.pl>
NNTP-Posting-Host: d-94-53-14.cyfronet.krakow.pl
Mime-Version: 1.0
X-Trace: info.cyf-kr.edu.pl 979996830 7457 149.156.1.174 (20 Jan 2001 13:20:30 GMT)
X-Complaints-To: news AT cyf-kr DOT edu DOT pl
NNTP-Posting-Date: 20 Jan 2001 13:20:30 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

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 :

Compiling: bugmain.cc
no errors
Creating: bug.exe
Error: bugmain.o: In function `main':
bugmain.cc(2) Error: undefined reference to `box<int>::move(int)'
There were some errors

Box is my template class and move is simple function inside bug ctemplate
class.
Can somebody help me ???????

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.

If You can help me, please write exacly what should be compiler & linker
options, and what I have to change inside my source files.
Maybe You can correct my project file, then send it to me
 maj_rafal AT poczta DOT onet DOT pl  )?

============ PROJECT WINDOW ==========
bug.cc
bugmain.cc
================== BUG.CC ================
template <class typ> void box<typ>::move(typ d) {
  x+=d;  y+=d;
}
================== BUGMAIN.CC =================
#include "bug.h"
main() {
  box<int> b;
  b.move(5);
}
================== BUG.H ===============
template <class typ>
class box {
  public :
    typ x,y;
    void move(typ d);
};
=========================================================

Thanks in advice ;-)
Rafał










- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019