472,353 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Problem with basic templates on GCC

Hi,
If this should be directed to another group, please let me know...
I've been working with templates for a few weeks and have been able to
develop some nice code on solaris using the Forte C++ compiler (version 7).
However, nothing related to templates seems to be compiling correctly when I
use g++ on netbsd. I can't tell if it is either: a problem with my code, a
problem with NetBSD, or a problem with GCC. I have tried to create the
most basic of tests to illustrate the problem. Could someone tell me why
this compiles and runs fine using the Forte compiler but does not with g++?

MyTemp.h
--------------------------
#include <iostream>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
MyTemp.cpp
----------------------------------------
#include "MyTemp.h"

template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include <MyTemp.h>
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

------------------------------------------------------
g++ -c -I./ -g -D_DEBUG -Wall -Wno-parentheses -c *.cpp
g++ *.o -o Test
/usr/lib/libstdc++.so: warning: reference to compatibility vfork(); include
<unistd.h> for correct reference
Test.o: In function `main':
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
*** Error code 1

Stop.
Jul 23 '05 #1
13 1855
Winbatch wrote:
Hi,
If this should be directed to another group, please let me know...
I've been working with templates for a few weeks and have been able to
develop some nice code on solaris using the Forte C++ compiler (version 7).
However, nothing related to templates seems to be compiling correctly when I
use g++ on netbsd. I can't tell if it is either: a problem with my code, a
problem with NetBSD, or a problem with GCC. I have tried to create the
most basic of tests to illustrate the problem. Could someone tell me why
this compiles and runs fine using the Forte compiler but does not with g++?

MyTemp.h
--------------------------
#include <iostream>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
MyTemp.cpp
----------------------------------------
#include "MyTemp.h"

template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
std::cout<<temp;
}

Test.cpp
------------------------------------------

// What's this? #include <unistd.h>
#include <iostream>
#include <string>
#include <MyTemp.h>
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

------------------------------------------------------
g++ -c -I./ -g -D_DEBUG -Wall -Wno-parentheses -c *.cpp
g++ *.o -o Test
/usr/lib/libstdc++.so: warning: reference to compatibility vfork(); include
<unistd.h> for correct reference
Test.o: In function `main':
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
*** Error code 1


It compiles fine here with g++ 3.4.2. Which version are you using? My
exact code:
#include <iostream>
#include <string>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
std::cout<<temp;
}
int main()
{
using namespace std;
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #2
The problem is that at the point of instantiation (MyTemp<string>
mt("TEST");, Test.cpp) compiler sees only declaration of template class
member functions (from MyTemp.h file) and no their definitions.
You should #include MyTemp.cpp into Test.cpp file. Because for template
classes definions (not only declarations) of all members must be visible at
the point of instantiation.
So you should change
#include <MyTemp.h>
to
#include "MyTemp.cpp"
in Test.cpp file.

But #include 'ing cpp file looks ugly.
I would advise you to rewrite your code as follows:

MyTemp.h
--------------------------
#include <iostream>
#include "MyTemp.hpp"

template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};

MyTemp.hpp hpp is commonly used extension for templates
implementation files
----------------------------------------
template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include "MyTemp.h"
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

There is a VERY GOOD book on C++ templates "C++ Templates: The Complete
Guide" by David Vandevoorde, Nicolai M. Josuttis, ISBN : 0-201-73484-2

Good Luck,
HappyHippy
"Winbatch" <wi******@techie.com> wrote in message
news:nd*********************@twister.nyc.rr.com...
Hi,
If this should be directed to another group, please let me know...
I've been working with templates for a few weeks and have been able to
develop some nice code on solaris using the Forte C++ compiler (version
7). However, nothing related to templates seems to be compiling correctly
when I use g++ on netbsd. I can't tell if it is either: a problem with my
code, a problem with NetBSD, or a problem with GCC. I have tried to
create the most basic of tests to illustrate the problem. Could someone
tell me why this compiles and runs fine using the Forte compiler but does
not with g++?

MyTemp.h
--------------------------
#include <iostream>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
MyTemp.cpp
----------------------------------------
#include "MyTemp.h"

template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include <MyTemp.h>
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

------------------------------------------------------
g++ -c -I./ -g -D_DEBUG -Wall -Wno-parentheses -c *.cpp
g++ *.o -o Test
/usr/lib/libstdc++.so: warning: reference to compatibility vfork();
include <unistd.h> for correct reference
Test.o: In function `main':
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
*** Error code 1

Stop.

Jul 23 '05 #3

"HappyHippy" <ka******@mail.ru> wrote in message
news:d1**********@charm.magnus.acs.ohio-state.edu...
The problem is that at the point of instantiation (MyTemp<string>
mt("TEST");, Test.cpp) compiler sees only declaration of template class
member functions (from MyTemp.h file) and no their definitions.
You should #include MyTemp.cpp into Test.cpp file. Because for template
classes definions (not only declarations) of all members must be visible
at the point of instantiation.
So you should change
#include <MyTemp.h>
to
#include "MyTemp.cpp"
in Test.cpp file.

But #include 'ing cpp file looks ugly.
I would advise you to rewrite your code as follows:

MyTemp.h
--------------------------
#include <iostream>
#include "MyTemp.hpp"

template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};

MyTemp.hpp hpp is commonly used extension for templates
implementation files
----------------------------------------
template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include "MyTemp.h"
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

There is a VERY GOOD book on C++ templates "C++ Templates: The Complete
Guide" by David Vandevoorde, Nicolai M. Josuttis, ISBN : 0-201-73484-2

Good Luck,
HappyHippy
"Winbatch" <wi******@techie.com> wrote in message
news:nd*********************@twister.nyc.rr.com...
Hi,
If this should be directed to another group, please let me know...
I've been working with templates for a few weeks and have been able to
develop some nice code on solaris using the Forte C++ compiler (version
7). However, nothing related to templates seems to be compiling correctly
when I use g++ on netbsd. I can't tell if it is either: a problem with
my code, a problem with NetBSD, or a problem with GCC. I have tried to
create the most basic of tests to illustrate the problem. Could someone
tell me why this compiles and runs fine using the Forte compiler but does
not with g++?

MyTemp.h
--------------------------
#include <iostream>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
MyTemp.cpp
----------------------------------------
#include "MyTemp.h"

template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include <MyTemp.h>
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

------------------------------------------------------
g++ -c -I./ -g -D_DEBUG -Wall -Wno-parentheses -c *.cpp
g++ *.o -o Test
/usr/lib/libstdc++.so: warning: reference to compatibility vfork();
include <unistd.h> for correct reference
Test.o: In function `main':
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
*** Error code 1

Stop.


HH,
Thanks, I will try it. Why would it work in some versions of gcc (as
reported by Ioannis), but not by others? Did it later become part of the
standard?
Jul 23 '05 #4

"Ioannis Vranos" <iv*@remove.this.grad.com> wrote in message
news:1110938952.429507@athnrd02...
Winbatch wrote:
Hi,
If this should be directed to another group, please let me know...
I've been working with templates for a few weeks and have been able to
develop some nice code on solaris using the Forte C++ compiler (version
7). However, nothing related to templates seems to be compiling correctly
when I use g++ on netbsd. I can't tell if it is either: a problem with
my code, a problem with NetBSD, or a problem with GCC. I have tried to
create the most basic of tests to illustrate the problem. Could someone
tell me why this compiles and runs fine using the Forte compiler but does
not with g++?

MyTemp.h
--------------------------
#include <iostream>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
MyTemp.cpp
----------------------------------------
#include "MyTemp.h"

template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{


std::cout<<temp;
}

Test.cpp
------------------------------------------

// What's this? #include <unistd.h>
#include <iostream>
#include <string>
#include <MyTemp.h>
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

------------------------------------------------------
g++ -c -I./ -g -D_DEBUG -Wall -Wno-parentheses -c *.cpp
g++ *.o -o Test
/usr/lib/libstdc++.so: warning: reference to compatibility vfork();
include <unistd.h> for correct reference
Test.o: In function `main':
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
*** Error code 1


It compiles fine here with g++ 3.4.2. Which version are you using? My
exact code:
#include <iostream>
#include <string>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
std::cout<<temp;
}
int main()
{
using namespace std;
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

--
Ioannis Vranos

http://www23.brinkster.com/noicys


Ioannis,
Can you provide the compile command you used?
Jul 23 '05 #5
> It compiles fine here with g++ 3.4.2. Which version are you using? My
exact code:

2.95
Jul 23 '05 #6
HH,

Your sample indicates that I should include the .hpp from the .h. Is that
right? Wouldn't the class need to be defined before the implemenation? (ie
shouldn't the .hpp include the .h instead?)

Winbatch
Jul 23 '05 #7
Winbatch wrote:
It compiles fine here with g++ 3.4.2. Which version are you using? My
exact code:


2.95

There's your problem. Upgrade to a more recent version if you can (2.95
had some problems with template code).

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays
Jul 23 '05 #8
"Artie Gold" <ar*******@austin.rr.com> wrote in message
news:39*************@individual.net...
Winbatch wrote:
It compiles fine here with g++ 3.4.2. Which version are you using? My
exact code:


2.95

There's your problem. Upgrade to a more recent version if you can (2.95
had some problems with template code).

HTH,
--ag


I thought I was seriously going nuts here. Unfortunately, it's not my
machine so I don't have much control. What do you think of the .hpp route
mentioned previously? I'm trying to implement it on that machine..
Jul 23 '05 #9
HH,

Just wanted to thank you - your suggestion to use the .hpp's not only helped
me to successfully compile on GCC 2.95 on NetBSD, but also on AIX 5.1 using
/usr/vacpp/bin/xlC. (Something I was struggling to accomplish as well).

Thanks again,
Winbatch
Jul 23 '05 #10
Winbatch wrote:
HH,

Just wanted to thank you - your suggestion to use the .hpp's not only helped
me to successfully compile on GCC 2.95 on NetBSD, but also on AIX 5.1 using
/usr/vacpp/bin/xlC. (Something I was struggling to accomplish as well).

Thanks again,
Winbatch

I missed the call before.

However, one point to be made is that as (virtually -- there's Comeau
and something else I believe) no one supports `export', there seems to
be limited utility in separating the templated class definition from its
templated member functions.[1] Where one needs to be visible, at least
some subset of the rest would need to be visible too.

Think of templates as a away of telling the compiler to generate code
for you on demand -- not as code itself. The definitions need to be
visible in any translation unit that use them.

HTH,
--ag

[1] Well, when we're dealing with small projects anyway; even in large
projects any underlying file structure should be transparent to its
clients. `#include'-ing a single `.h' file should be sufficient.
--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays
Jul 23 '05 #11
Winbatch wrote:
Ioannis,
Can you provide the compile command you used?

#include <iostream>
#include <string>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
std::cout<<temp;
}
int main()
{
using namespace std;
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

C:\c>g++ temp.cpp -o temp.exe

C:\c>temp
In Test
TEST
C:\c>g++ -v
Reading specs from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as
--host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls
--enable
-languages=c,c++,f77,ada,objc,java --disable-win32-registry
--disable-shared --e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x
--enable-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter
--enable-hash-synchroniz
ation --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.2 (mingw-special)

C:\c>

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #12
Yes you are completely right.
Sorry.
It should look like this:

MyTemp.h
--------------------------
#include <iostream>

template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};

#include "MyTemp.hpp"
-------------------------

Regards,
HappyHippy

"Winbatch" <wi******@techie.com> wrote in message
news:ye*********************@twister.nyc.rr.com...
HH,

Your sample indicates that I should include the .hpp from the .h. Is that
right? Wouldn't the class need to be defined before the implemenation?
(ie shouldn't the .hpp include the .h instead?)

Winbatch

Jul 23 '05 #13
There is a way to make it work without #include 'ing implementation to
declaration. Keyword "export" should be used for this purpose according to
the standard. BUT. Neither VC++ 7.1 nor gcc 3.3.x implement this feature as
far as I know.

It works in Ioannis' example because (as I understood from his post) he put
everything in a single file. So it is almost the same as using #include
which I suggested to use.

Regards,
HappyHippy

"Winbatch" <wi******@techie.com> wrote in message
news:N1*********************@twister.nyc.rr.com...

"HappyHippy" <ka******@mail.ru> wrote in message
news:d1**********@charm.magnus.acs.ohio-state.edu...
The problem is that at the point of instantiation (MyTemp<string>
mt("TEST");, Test.cpp) compiler sees only declaration of template class
member functions (from MyTemp.h file) and no their definitions.
You should #include MyTemp.cpp into Test.cpp file. Because for template
classes definions (not only declarations) of all members must be visible
at the point of instantiation.
So you should change
#include <MyTemp.h>
to
#include "MyTemp.cpp"
in Test.cpp file.

But #include 'ing cpp file looks ugly.
I would advise you to rewrite your code as follows:

MyTemp.h
--------------------------
#include <iostream>
#include "MyTemp.hpp"

template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};

MyTemp.hpp hpp is commonly used extension for templates
implementation files
----------------------------------------
template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include "MyTemp.h"
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

There is a VERY GOOD book on C++ templates "C++ Templates: The Complete
Guide" by David Vandevoorde, Nicolai M. Josuttis, ISBN : 0-201-73484-2

Good Luck,
HappyHippy
"Winbatch" <wi******@techie.com> wrote in message
news:nd*********************@twister.nyc.rr.com...
Hi,
If this should be directed to another group, please let me know...
I've been working with templates for a few weeks and have been able to
develop some nice code on solaris using the Forte C++ compiler (version
7). However, nothing related to templates seems to be compiling
correctly when I use g++ on netbsd. I can't tell if it is either: a
problem with my code, a problem with NetBSD, or a problem with GCC. I
have tried to create the most basic of tests to illustrate the problem.
Could someone tell me why this compiles and runs fine using the Forte
compiler but does not with g++?

MyTemp.h
--------------------------
#include <iostream>
template <class T> class MyTemp
{
private:
T temp;

public:
MyTemp (T temp1);
void print();
};
MyTemp.cpp
----------------------------------------
#include "MyTemp.h"

template<class T> MyTemp<T>::MyTemp( T temp1 )
{
temp = temp1;
}
template<class T> void MyTemp<T>::print()
{
cout<<temp;
}

Test.cpp
------------------------------------------
#include <unistd.h>
#include <iostream>
#include <string>
#include <MyTemp.h>
using namespace std;
int main()
{
cout<<"In Test"<<endl;
MyTemp<string> mt("TEST");
mt.print();
return 0;
}

------------------------------------------------------
g++ -c -I./ -g -D_DEBUG -Wall -Wno-parentheses -c *.cpp
g++ *.o -o Test
/usr/lib/libstdc++.so: warning: reference to compatibility vfork();
include <unistd.h> for correct reference
Test.o: In function `main':
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:7: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::MyTemp(basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> >)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
/arpa/ag/d//Test/Test.cpp:8: undefined reference to
`MyTemp<basic_string<char, string_char_traits<char>,
__default_alloc_template<false, 0> > >::print(void)'
*** Error code 1

Stop.


HH,
Thanks, I will try it. Why would it work in some versions of gcc (as
reported by Ioannis), but not by others? Did it later become part of the
standard?

Jul 23 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JP SIngh | last post by:
Thanks to Manohar for writing the basic code for displaying the managers and the employees in a tree like structure. I have adapted the code...
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to...
5
by: Michael Olea | last post by:
Here is a design problem I ran into this am - and I have cleaned the bathroom, scrubbed toilet sink and tub, windexed all glass, mopped the floor,...
11
by: Rolf Barbakken | last post by:
I have an xml with records like this one: <a:response> <a:href>http://server/public/sol/comp/1049306.eml</a:href> <a:propstat>...
6
by: B. Williams | last post by:
I have a problem dealing with class template where I was to write a class and after submitting the class, this is the feedback I got back from the...
9
by: Jerome Durand | last post by:
Hello, I'm trying to write something along the following lines but I cannot get this to compile. template <typename derivedstruct Base {...
2
by: timwilson | last post by:
I am a developer..... not a designer :) I am looking for a place to find some templates, layouts, etc. for a simple web application that I am...
1
by: Nilla | last post by:
Hi! I have downloaded and installed the design templates Personal Design and Basic from http://msdn.microsoft.com/en-us/asp.net/aa336613.aspx...
6
by: pauldepstein | last post by:
Let double NR( double x, double(*)(const double&) f ) be the signature of a Newton-Raphson function NR. Here, f is a function which returns a...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.