[Insight-users] undefined reference Templated Class

Lars Nygard lnygard at yahoo.com
Thu Sep 6 11:43:59 EDT 2007


Hi Gaetan,



Thanks for the help. Ive tried that but than I get the following
error:

In file included from C:\Insight\myPrograms\generateProblems\/gradient.h:98,
                 from C:\Insight\myPrograms\generateProblems\/main.h:18,
                 from C:\Insight\myPrograms\generateProblems\main.cxx:13:
C:\Insight\myPrograms\generateProblems\/gradient.cxx:18: error: declaration of `class
C:\Insight\myPrograms\generateProblems\/gradient.h:20: error:  shadows template parm
C:\Insight\myPrograms\generateProblems\/gradient.cxx:20: error: cannot declare member
ient<TImage>::gradient' within `gradient<TImage>'
C:\Insight\myPrograms\generateProblems\/gradient.cxx:47: error: declaration of `class
C:\Insight\myPrograms\generateProblems\/gradient.h:20: error:  shadows template parm
C:\Insight\myPrograms\generateProblems\/gradient.cxx:51: error: cannot declare member
ient<TImage>::LoadImageA' within `gradient<TImage>'
C:\Insight\myPrograms\generateProblems\/gradient.cxx:66: error: declaration of `class
C:\Insight\myPrograms\generateProblems\/gradient.h:20: error:  shadows template parm
C:\Insight\myPrograms\generateProblems\/gradient.cxx:70: error: cannot declare member
ient<TImage>::SaveImage' within `gradient<TImage>'
C:\Insight\myPrograms\generateProblems\/gradient.cxx:84: error: declaration of `class
C:\Insight\myPrograms\generateProblems\/gradient.h:20: error:  shadows template parm
C:\Insight\myPrograms\generateProblems\/gradient.cxx:88: error: cannot declare member
ient<TImage>::CompGradient' within `gradient<TImage>'
mingw32-make[2]: *** [CMakeFiles/generateProblems.dir/main.obj] Error 1
mingw32-make[1]: *** [CMakeFiles/generateProblems.dir/all] Error 2
mingw32-make: *** [all] Error 2
----- Original Message ----
From: Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr>
To: Lars Nygard <lnygard at yahoo.com>
Cc: insight-users at itk.org
Sent: Thursday, September 6, 2007 7:37:04 AM
Subject: Re: [Insight-users] undefined reference Templated Class


Hi Lars,

Your gradient class is templated, so you have to include the cxx file  
at the end of the header to make it work.

#include "gradient.cxx"

Because of the template, you can't (easily) build the code in  
your .cxx file and put it in a shared object.

Regards,

Gaëtan




Le 6 sept. 07 à 16:28, Lars Nygard a écrit :

> hi everybody,
>
> Id really appreciate some help with this. I don't know if this has
> something to do with ITK or if it's just basic c++. Whenever I try
> to make an instance of gradient Im getting an undefined reference
> Linker error:
>
> Linking CXX executable generateProblems.exe
> CMakeFiles/generateProblems.dir/main.obj:main.cxx:(.text+0x288):  
> undefined reference to `gradient<it
> k::Image<unsigned short, 3u> >::gradient()'
> collect2: ld returned 1 exit status
> mingw32-make[2]: *** [generateProblems.exe] Error 1
> mingw32-make[1]: *** [CMakeFiles/generateProblems.dir/all] Error 2
> mingw32-make: *** [all] Error 2
>
> Ive attached both .h and cxx class, hope this works.
> thanks for any help.
> lars
>
>
>
>
>
> _________________________________________________________
> Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
> notisblokk. http://no.mail.yahoo.com
> <gradient.cxx>
> <gradient.h>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users

--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr








      
_________________________________________________________
Alt i én. Få Yahoo! Mail med adressekartotek, kalender og
notisblokk. http://no.mail.yahoo.com


More information about the Insight-users mailing list