Thread View: comp.std.c++
2 messages
2 total messages
Started by Jesse Chou WSG/SECG
Thu, 17 Dec 1992 23:14
need help compiling (linking) Borland C++ programs using templates
Author: Jesse Chou WSG/SECG
Date: Thu, 17 Dec 1992 23:14
Date: Thu, 17 Dec 1992 23:14
34 lines
1478 bytes
1478 bytes
This may be a very basic and silly question to ask but I am new to Borland c++. It is greatly appreciated that someone could enlighten me or give me pointer to a FAQ. I am writing a list class using template and got link error: Error: Undefined symbol slist_base::append(slink near*) in module tpc.cpp I had a similar error using other c++ compiler and found that I have to use a command line switch with the compiler. I suppose that someone could easily point to me what I should do in my makefile. Or maybe there is other problems that I am not aware of. In any rate, thanks in advance. Jesse -- Jesse Chou -- chou@riscee.enet.dec.com These words are entered into net by the keyboard. I am not responsible for them; neither is my employer. -- Jesse Chou -- chou@riscee.enet.dec.com These words are entered into net by the keyboard. I am not responsible for them; neither is my employer.
Re: need help compiling (linking) Borland C++ programs using templates
Author: Jamshid Afshar
Date: Tue, 22 Dec 1992 21:52
Date: Tue, 22 Dec 1992 21:52
39 lines
1988 bytes
1988 bytes
In article <1992Dec17.231411.10943@engage.pko.dec.com> chou@riscee.pko.dec.com (Jesse Chou WSG/SECG) writes:
>This may be a very basic and silly question to ask but I am new to Borland
>c++. It is greatly appreciated that someone could enlighten me or give me
>pointer to a FAQ.
The comp.lang.c++ FAQL is available by anonymous ftp at
sun.soe.clarkson.edu in the file pub/C++/FAQ (though there's not much
on templates).
>I am writing a list class using template and got link error:
>Error: Undefined symbol slist_base::append(slink near*) in module tpc.cpp
>I had a similar error using other c++ compiler and found that I have to use
>a command line switch with the compiler.
Different compilers currently do not handle the generation of template
functions in the same way. The ARM leaves a lot unspecified and I'm
not sure what ANSI C++ will say about it. Make sure you read your
compiler manuals as there are often different ways to do it even with
the same compiler, each method offering different tradeoffs.
The easiest way to do deal with this under BC++ (and I believe gcc) is
to just #include the .cpp file containing the non-inline template
functions in the corresponding header file.
// List.h
#ifndef List_H
#define List_H
template<class T> class List { /*...*/ };
//...
#ifndef DONT_NEED_CPP
#include "List.cpp"
#endif
#endif // List_H
Jamshid Afshar
jamshid@emx.utexas.edu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads