This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Code compiles with g++ 3.3 but not g++ 4.4
- From: Axel Freyn <axel-freyn at gmx dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 16 Oct 2009 21:08:43 +0200
- Subject: Re: Code compiles with g++ 3.3 but not g++ 4.4
- References: <25929745.post@talk.nabble.com>
Hi David,
On Fri, Oct 16, 2009 at 10:58:33AM -0700, daviddoria wrote:
>
> With this code:
> http://www.rpi.edu/~doriad/Daniweb/maxflow/
> If I run
>
> g++ Example.cpp graph.cpp
>
> with g++ 3.3, everything works fine. However if I run the same command with
> g++ 4.4, I get this error:
>
> Example.cpp:(.text+0x38): undefined reference to `Graph<int, int,
> int>::Graph(int, int, void (*)(char*))'
as far as I understand the C++ - standard, the statement "template class
Graph<int,int,int>;" does define the class "Graph<int,int,int>" and
declare all member functions. However, it does NOT define the member
functions of Graph<init,int,int>.
> Does anyone know how I can get this to work with g++ 4.4?
If you explicitely instantiate the template member function, it will
work:
template class Graph<int,int,int>::Graph(int, int, void (*)(char *));
(Besides: your code does not compile - "NULL" is not defined, you should
a e.g. #include <cstdlib> :-)
HTH,
Axel