L
Lord Labakudas
Hi,
I have the following simple template implementation:
// -------------- b.h ----------------- //
template <class t>
class b
{
public:
b() ;
~b() ;
} ;
// -------------- b.cpp --------------- //
#include "b.h"
template <class t>
b<t>::b()
{
}
template <class t>
b<t>::~b()
{
}
// --------------- main.cpp ------------- //
#include "b.h"
main()
{
b<int> bi ;
b <float> bf ;
}
When the compile the above program main.cpp using,
gcc main.cpp b.cpp
I get the following error message.
/tmp/cc6si1GJ.o(.text+0x19): In function `main':
: undefined reference to `b<int>::b[in-charge]()'
/tmp/cc6si1GJ.o(.text+0x28): In function `main':
: undefined reference to `b<float>::b[in-charge]()'
/tmp/cc6si1GJ.o(.text+0x37): In function `main':
: undefined reference to `b<float>::~b [in-charge]()'
/tmp/cc6si1GJ.o(.text+0x4e): In function `main':
: undefined reference to `b<int>::~b [in-charge]()'
/tmp/cc6si1GJ.o(.text+0x6b): In function `main':
: undefined reference to `b<int>::~b [in-charge]()'
/tmp/cc6si1GJ.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Am I missing something ?
Thanks,
LL.
I have the following simple template implementation:
// -------------- b.h ----------------- //
template <class t>
class b
{
public:
b() ;
~b() ;
} ;
// -------------- b.cpp --------------- //
#include "b.h"
template <class t>
b<t>::b()
{
}
template <class t>
b<t>::~b()
{
}
// --------------- main.cpp ------------- //
#include "b.h"
main()
{
b<int> bi ;
b <float> bf ;
}
When the compile the above program main.cpp using,
gcc main.cpp b.cpp
I get the following error message.
/tmp/cc6si1GJ.o(.text+0x19): In function `main':
: undefined reference to `b<int>::b[in-charge]()'
/tmp/cc6si1GJ.o(.text+0x28): In function `main':
: undefined reference to `b<float>::b[in-charge]()'
/tmp/cc6si1GJ.o(.text+0x37): In function `main':
: undefined reference to `b<float>::~b [in-charge]()'
/tmp/cc6si1GJ.o(.text+0x4e): In function `main':
: undefined reference to `b<int>::~b [in-charge]()'
/tmp/cc6si1GJ.o(.text+0x6b): In function `main':
: undefined reference to `b<int>::~b [in-charge]()'
/tmp/cc6si1GJ.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Am I missing something ?
Thanks,
LL.