[Insight-users] Can I use ITK as a encapsulation function isolated outside of ITK?

Luis Ibanez luis.ibanez at kitware.com
Mon Aug 28 12:01:10 EDT 2006


Hi Goo,

Yes you can encapsulate an ITK pipeline as an independent
function call.

You must however be careful regarding memory allocations
and release.


For a full list of details on how to encapsulate ITK in
functions please look at the Tutorials:

      http://www.itk.org/HTML/Tutorials.htm

In particular to

   "Getting Started V: Integrating ITK in your Application."
   http://www.itk.org/CourseWare/Training/GettingStarted-V.pdf


Examples of applications that encapsulate ITK pipelines as
functions can be found in:


     InsightApplications/VolviewPlugins


About the link problem that you are finding with ITKFilterLib,
it is probably du to mixing compilation modes between your
build process for the library and the build process for the
application that uses the library.


Typical mistakes are:

1) build the library as Debug, and the application as Release
2) build the library as Release and the application as Debug


Visual Studio probably already warned you about the mixing
of those libraries. Many people make the mistake of ignoring
the warning and forcing Visual Studio to mix the libraries.


Please make sure that you use the *exact same* compilation
modes for all the components of your applicaions.



   Regards,


      Luis



--------------------
Goo wrote:
> Hi,everyone:
> 
> Can I use ITK code as a encapsulation function or class?
> After encapsulation function, it maybe only  easily  to  use ITK 
> function as
> general call  function.
> 
> What should I do?
> 
> Note :
> I refer to InsightApplication/ITKFilterLib
> / and build this project.
> It can generate a .lib file.
> But when I test this lib separately,
> the code
> itkFilterLib filter(inputDimSize, inputOrigin, inputSpacing);
> has a link error as below:
> How should I solve this problem?
> 
> =====================================================
> --------------------Configuration: ITKFilterLibTest - Win32 
> Debug--------------------
> Linking...
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::ios_base::Init::Init(void)" (??0Init at ios_base@std@@QAE at XZ) already 
> defined in libcpd.lib(iostream.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::ios_base::Init::~Init(void)" (??1Init@ ios_base at std@@QAE at XZ) 
> already defined in libcpd.lib(iostream.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::_Winit::_Winit(void)" (??0_Winit at std@@QAE at XZ) already defined in 
> libcpd.lib (wiostrea.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::_Winit::~_Winit(void)" (??1_Winit at std@@QAE at XZ) already defined in 
> libcpd.lib(wiostrea.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> >::~basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> >(void)" 
> (??1?$basic_strin
> g at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAE at XZ) already defined 
> in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: char const * 
> __thiscall std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@ 
> DU?$char_traits at D@std@@V?$allocator at D@2@@std@@Q
> BEPBDXZ) already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "class 
> std::basic_ostream<char,struct std::char_traits<char> > & __cdecl 
> std::operator<<(class std::basic_ostream<char,struct 
> std::char_traits<char> > &,char const *)" (??6std@@ 
> YAAAV?$basic_ostream at DU?$cha
> r_traits at D@std@@@0 at AAV10@PBD at Z) already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: virtual __thiscall 
> std::basic_ios<char,struct std::char_traits<char> 
>  >::~basic_ios<char,struct std::char_traits<char> >(void)" 
> (??1?$basic_ios@ DU?$char_traits at D@std@@@std@@UAE at XZ) already defined
> in libcpd.lib(iostream.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "protected: __thiscall 
> std::basic_ios<char,struct std::char_traits<char> 
>  >::basic_ios<char,struct std::char_traits<char> >(void)" 
> (??0?$basic_ios@ DU?$char_traits at D@std@@@std@@IAE at XZ) already defined in lib
> cpd.lib(iostream.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class 
> std::basic_ostream<char,struct std::char_traits<char> > & __thiscall 
> std::basic_ostream<char,struct std::char_traits<char> 
>  >::operator<<(float)" (??6?$basic_ostream@ DU?$char_traits at D@std@@@s
> td@@QAEAAV01 at M@Z) already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class 
> std::basic_ostream<char,struct std::char_traits<char> > & __thiscall 
> std::basic_ostream<char,struct std::char_traits<char> 
>  >::operator<<(class std::basic_ostream<char,struct std::char_traits
> <char> > & (__cdecl*)(class std::basic_ostream<char,struct 
> std::char_traits<char> > &))" 
> (??6?$basic_ostream at DU?$char_traits at D@std@@@std@@QAEAAV01 at P6AAAV01@AAV01@@Z at Z) 
> already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "class 
> std::basic_ostream<char,struct std::char_traits<char> > & __cdecl 
> std::endl(class std::basic_ostream<char,struct std::char_traits<char> > 
> &)" (?endl at std@@ YAAAV?$basic_ostream at DU?$char_traits at D@std@@
> @1 at AAV21@@Z) already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > & __thiscall std::basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> >::operator=(ch
> ar const *)" 
> (??4?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAEAAV01 at PBD@Z) 
> already defined in libcpd.lib(locale0.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> >::basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> >(class 
> std::allocator<char
>  > const &)" 
> (??0?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAE at ABV?$allocator at D@1@@Z) 
> already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > & __thiscall std::basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> >::operator=(cl
> ass std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > const &)" 
> (??4?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAEAAV01 at ABV01@@Z) 
> already defined in ITKFilterLibTest.obj
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > & __thiscall std::basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> >::operator+=(c
> lass std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > const &)" 
> (??Y?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAEAAV01 at ABV01@@Z) 
> already defined in libcpd.lib(locale.obj)
> msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> >::basic_string<char,struct 
> std::char_traits<char>,class std::allocator<char> >(char const *,class 
> std::a
> llocator<char> const &)" 
> (??0?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAE at PBDABV?$allocator at D@1@@Z) 
> already defined in ITKFilterLibTest.obj
> MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: "public: virtual __thiscall 
> exception::~exception(void)" (??1exception@@ UAE at XZ) already defined in 
> LIBCD.lib(stdexcpt.obj)
> MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: "public: __thiscall 
> exception::exception(void)" (??0exception@@QAE at XZ) already defined in 
> LIBCD.lib(stdexcpt.obj)
> MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: "public: int __thiscall 
> type_info::operator==(class type_info const &)const " 
> (??8type_info@@QBEHABV0@@Z) already defined in LIBCD.lib(typinfo.obj)
> LINK : warning LNK4098: defaultlib "MSVCRTD" conflicts with use of other 
> libs; use /NODEFAULTLIB:library
> Example_ITKFilterLib.lib(ITKFilterLib.obj) : error LNK2001: unresolved 
> external symbol "public: static void __cdecl itk::LightObject::operator 
> delete(void *)" (??3LightObject at itk@@SAXPAX at Z)
> Example_ITKFilterLib.lib( ITKFilterLib.obj) : error LNK2001: unresolved 
> external symbol "public: static void * __cdecl 
> itk::LightObject::operator new(unsigned int)" (??2LightObject at itk@@SAPAXI at Z)
> Example_ITKFilterLib.lib(ITKFilterLib.obj ) : error LNK2001: unresolved 
> external symbol "protected: virtual void __thiscall 
> itk::ProcessObject::RestoreInputReleaseDataFlags(void)" 
> (?RestoreInputReleaseDataFlags at ProcessObject@itk@@MAEXXZ)
> Example_ITKFilterLib.lib( ITKFilterLib.obj) : error LNK2001: unresolved 
> external symbol "protected: virtual void __thiscall 
> itk::ProcessObject::CacheInputReleaseDataFlags(void)" 
> (?CacheInputReleaseDataFlags at ProcessObject@itk@@MAEXXZ)
> Example_ITKFilterLib.lib(ITKFilterLib.obj) : error LNK2001: unresolved 
> external symbol "protected: virtual void __thiscall 
> itk::ProcessObject::PropagateResetPipeline(void)" 
> (?PropagateResetPipeline at ProcessObject@itk @@MAEXXZ)
> Example_ITKFilterLib.lib(ITKFilterLib.obj) : error LNK2001: unresolved 
> external symbol "protected: virtual void __thiscall 
> itk::ProcessObject::GenerateOutputInformation(void)" 
> (?GenerateOutputInformation@ ProcessObject at itk@@MAEXXZ)
> Example_ITKFilterLib.lib(ITKFilterLib.obj) : error LNK2001: unresolved 
> external symbol "protected: virtual void __thiscall 
> itk::ProcessObject::GenerateOutputRequestedRegion(class itk::DataObject 
> *)" (?GenerateOutputRequestedRegion@ ProcessObject at itk@
> @MAEXPAVDataObject at 2@@Z)
> .
> .
> .
> .
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users




More information about the Insight-users mailing list