[Insight-users] I'm New... linking issue under MS Visual Studio 8. Am using CMake
Perry Horwich
perryhorwich at gmail.com
Sun Jun 7 07:34:05 EDT 2009
Hi Dan,
Thanks for your reply.
Yes. Adding ITKIO to the TARGET_LINK_LIBRARIES statement in CMakeLists.txt
fixed the issue.
Is there someplace I can find a list of valid CMake directives for ITK?
Or, is there someway I could have discovered that ITKIO was the label to add
to TARGET_LINK_LIBRARIES for the classes I was using? I wonder if I will
come across this problem as I explore more of the ITK library.
Or... is there some "ITK_LINK_ALL" label that I could have tried? If so, it
might be a little slower linking, but would have saved me a lot of time
otherwise. This might be an inelegant solution, but it could save others
some "banging head against table" time.
Best -
Perry
Dan Mueller-2 wrote:
>
> Hi Perry,
>
> Welcome to ITK!
>
> Firstly, thank you for your clear description of your problem.
>
> It seems you are missing some libraries required for the linking. Try
> replacing
> TARGET_LINK_LIBRARIES(ConnectedThresholdImageFilter ITKCommon)
> with
> TARGET_LINK_LIBRARIES(ConnectedThresholdImageFilter ITKCommon
> ITKIO ITKNumerics)
>
> This is how the example ConnectedThresholdImageFilter is linked in
> Examples/Segmentation/CMakeLists.txt
>
> Pleas let us know if this works for you.
>
> Cheers, Dan
>
>
> 2009/6/7 <phorwich at bidmc.harvard.edu>:
>> Hi All,
>>
>>
>>
>> This is another post about trouble linking. My current state of affairs
>> is:
>>
>>
>>
>> + Downloaded and built ITK with CMake.
>>
>> + Built ITK_BIN successfully with MS Visual Studio 2008 under Win
>> XP
>>
>> + Made a new project 'Hello World' and copy/pasted the code from
>> the
>> examples directory
>>
>> + HelloWorld built and executed successfully
>>
>>
>>
>> + Did something similar with 'DicomSeriesReadImageWrite2' and
>> everything worked well.
>>
>>
>>
>> + Made a new project 'ConnectedThresholdImageFilter'
>>
>> + copy/pasted code from the examples directory
>>
>> + modified CMakeList.txt so it looks like:
>>
>>
>>
>> # This is the root ITK CMakeLists file.
>>
>> CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
>>
>> IF(COMMAND CMAKE_POLICY)
>>
>> CMAKE_POLICY(SET CMP0003 NEW)
>>
>> ENDIF(COMMAND CMAKE_POLICY)
>>
>>
>>
>>
>>
>> # This project is designed to be built outside the Insight source tree.
>>
>> PROJECT(ConnectedThresholdImageFilter)
>>
>>
>>
>> # Find ITK.
>>
>> FIND_PACKAGE(ITK REQUIRED)
>>
>> INCLUDE(${ITK_USE_FILE})
>>
>>
>>
>> ADD_EXECUTABLE(ConnectedThresholdImageFilter
>> ConnectedThresholdImageFilter.cxx )
>>
>>
>>
>> TARGET_LINK_LIBRARIES(ConnectedThresholdImageFilter ITKCommon)
>>
>>
>>
>> + Run CMake
>>
>> + Build ConnectedThresholdImageFilter project
>>
>> + Code compiles, no errors
>>
>> + When it comes time to link, I get 17 errors that look like:
>>
>> ------ Build started: Project: ConnectedThresholdImageFilter,
>> Configuration:
>> Debug Win32 ------
>>
>> Compiling...
>>
>> ConnectedThresholdImageFilter.cxx
>>
>> Linking...
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: static class itk::SmartPointer<class itk::ImageIOBase>
>> __cdecl itk::ImageIOFactory::CreateImageIO(char const *,enum
>> itk::ImageIOFactory::FileModeType)"
>> (?CreateImageIO at ImageIOFactory@itk@@SA?AV?$SmartPointer at VImageIOBase@itk@@@2 at PBDW4FileModeType@12@@Z)
>> referenced in function
>> __catch$?GenerateOutputInformation@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@UAEXXZ$0
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: virtual __thiscall
>> itk::ImageIORegion::~ImageIORegion(void)"
>> (??1ImageIORegion at itk@@UAE at XZ) referenced in function "public: virtual
>> void
>> __thiscall itk::ImageFileReader<class itk::Image<float,2>,class
>> itk::DefaultConvertPixelTraits<float>
>> >::EnlargeOutputRequestedRegion(class
>> itk::DataObject *)"
>> (?EnlargeOutputRequestedRegion@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@UAEXPAVDataObject at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: __thiscall itk::ImageIORegion::ImageIORegion(unsigned
>> int)"
>> (??0ImageIORegion at itk@@QAE at I@Z) referenced in function "public: virtual
>> void
>> __thiscall itk::ImageFileReader<class itk::Image<float,2>,class
>> itk::DefaultConvertPixelTraits<float>
>> >::EnlargeOutputRequestedRegion(class
>> itk::DataObject *)"
>> (?EnlargeOutputRequestedRegion@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@UAEXPAVDataObject at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: long __thiscall
>> itk::ImageIOBase::GetImageSizeInBytes(void)const "
>> (?GetImageSizeInBytes at ImageIOBase@itk@@QBEJXZ) referenced in function
>> __catch$?GenerateData@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@MAEXXZ$0
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: __thiscall itk::ImageIORegion::ImageIORegion(class
>> itk::ImageIORegion const &)" (??0ImageIORegion at itk@@QAE at ABV01@@Z)
>> referenced
>> in function
>> __catch$?GenerateData@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@MAEXXZ$0
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "class std::basic_ostream<char,struct std::char_traits<char> > &
>> __cdecl itk::operator<<(class std::basic_ostream<char,struct
>> std::char_traits<char> > &,class itk::ImageIORegion const &)"
>> (??6itk@@YAAAV?$basic_ostream at DU?$char_traits at D@std@@@std@@AAV12 at ABVImageIORegion@0@@Z)
>> referenced in function
>> __catch$?GenerateData@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@MAEXXZ$0
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: bool __thiscall itk::ImageIORegion::IsInside(class
>> itk::ImageIORegion const &)const "
>> (?IsInside at ImageIORegion@itk@@QBE_NABV12@@Z) referenced in function
>> "public:
>> virtual void __thiscall itk::ImageFileWriter<class itk::Image<unsigned
>> char,2> >::Write(void)"
>> (?Write@?$ImageFileWriter at V?$Image at E$01 at itk@@@itk@@UAEXXZ)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: void __thiscall itk::ImageIORegion::operator=(class
>> itk::ImageIORegion const &)" (??4ImageIORegion at itk@@QAEXABV01@@Z)
>> referenced
>> in function "public: virtual void __thiscall itk::ImageFileWriter<class
>> itk::Image<unsigned char,2> >::Write(void)"
>> (?Write@?$ImageFileWriter at V?$Image at E$01 at itk@@@itk@@UAEXXZ)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: __thiscall itk::ImageIORegion::ImageIORegion(void)"
>> (??0ImageIORegion at itk@@QAE at XZ) referenced in function "public: virtual
>> void
>> __thiscall itk::ImageFileWriter<class itk::Image<unsigned char,2>
>>>::Write(void)" (?Write@?$ImageFileWriter at V?$Image at E$01 at itk@@@itk@@UAEXXZ)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: void __thiscall
>> itk::ImageIOBase::SetNumberOfDimensions(unsigned int)"
>> (?SetNumberOfDimensions at ImageIOBase@itk@@QAEXI at Z) referenced in function
>> "public: virtual void __thiscall itk::ImageFileWriter<class
>> itk::Image<unsigned char,2> >::Write(void)"
>> (?Write@?$ImageFileWriter at V?$Image at E$01 at itk@@@itk@@UAEXXZ)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: void __thiscall itk::ImageIORegion::SetIndex(unsigned
>> long,long)" (?SetIndex at ImageIORegion@itk@@QAEXKJ at Z) referenced in
>> function
>> "public: static void __cdecl itk::ImageIORegionAdaptor<2>::Convert(class
>> itk::ImageRegion<2> const &,class itk::ImageIORegion &,class
>> itk::Index<2>
>> const &)"
>> (?Convert@?$ImageIORegionAdaptor@$01 at itk@@SAXABV?$ImageRegion@$01 at 2@AAVImageIORegion at 2@ABV?$Index@$01 at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: void __thiscall itk::ImageIORegion::SetSize(unsigned
>> long,unsigned long)" (?SetSize at ImageIORegion@itk@@QAEXKK at Z) referenced in
>> function "public: static void __cdecl
>> itk::ImageIORegionAdaptor<2>::Convert(class itk::ImageRegion<2> const
>> &,class itk::ImageIORegion &,class itk::Index<2> const &)"
>> (?Convert@?$ImageIORegionAdaptor@$01 at itk@@SAXABV?$ImageRegion@$01 at 2@AAVImageIORegion at 2@ABV?$Index@$01 at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: unsigned int __thiscall
>> itk::ImageIORegion::GetImageDimension(void)const "
>> (?GetImageDimension at ImageIORegion@itk@@QBEIXZ) referenced in function
>> "public: static void __cdecl itk::ImageIORegionAdaptor<2>::Convert(class
>> itk::ImageRegion<2> const &,class itk::ImageIORegion &,class
>> itk::Index<2>
>> const &)"
>> (?Convert@?$ImageIORegionAdaptor@$01 at itk@@SAXABV?$ImageRegion@$01 at 2@AAVImageIORegion at 2@ABV?$Index@$01 at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: long __thiscall itk::ImageIORegion::GetIndex(unsigned
>> long)const " (?GetIndex at ImageIORegion@itk@@QBEJK at Z) referenced in
>> function
>> "public: static void __cdecl itk::ImageIORegionAdaptor<2>::Convert(class
>> itk::ImageIORegion const &,class itk::ImageRegion<2> &,class
>> itk::Index<2>
>> const &)"
>> (?Convert@?$ImageIORegionAdaptor@$01 at itk@@SAXABVImageIORegion at 2@AAV?$ImageRegion@$01 at 2@ABV?$Index@$01 at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: unsigned long __thiscall
>> itk::ImageIORegion::GetSize(unsigned long)const "
>> (?GetSize at ImageIORegion@itk@@QBEKK at Z) referenced in function "public:
>> static
>> void __cdecl itk::ImageIORegionAdaptor<2>::Convert(class
>> itk::ImageIORegion
>> const &,class itk::ImageRegion<2> &,class itk::Index<2> const &)"
>> (?Convert@?$ImageIORegionAdaptor@$01 at itk@@SAXABVImageIORegion at 2@AAV?$ImageRegion@$01 at 2@ABV?$Index@$01 at 2@@Z)
>>
>> ConnectedThresholdImageFilter.obj : error LNK2019: unresolved external
>> symbol "public: class std::basic_string<char,struct
>> std::char_traits<char>,class std::allocator<char> > __thiscall
>> itk::ImageIOBase::GetComponentTypeAsString(enum
>> itk::ImageIOBase::IOComponentType)const "
>> (?GetComponentTypeAsString at ImageIOBase@itk@@QBE?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@W4IOComponentType at 12@@Z)
>> referenced in function "protected: void __thiscall
>> itk::ImageFileReader<class itk::Image<float,2>,class
>> itk::DefaultConvertPixelTraits<float> >::DoConvertBuffer(void *,unsigned
>> long)"
>> (?DoConvertBuffer@?$ImageFileReader at V?$Image at M$01 at itk@@V?$DefaultConvertPixelTraits at M@2@@itk@@IAEXPAXK at Z)
>>
>> C:\itkproj\connThreshImgFilter\connThreshImgFilterBin\Debug\ConnectedThresholdImageFilter.exe
>> : fatal error LNK1120: 16 unresolved externals
>>
>> Build log was saved at
>> "file://c:\itkproj\connThreshImgFilter\connThreshImgFilterBin\ConnectedThresholdImageFilter.dir\Debug\BuildLog.htm"
>>
>> ConnectedThresholdImageFilter - 17 error(s), 0 warning(s)
>>
>> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
>> ===========
>>
>>
>>
>> Alas.... After a couple of hours of trying various methods of pointing
>> the
>> linker in the right direction, I seem to have hit a wall. Is it possible
>> this example code uses classes that are not part of the distribution
>> code? I
>> can't even be sure which line of code is generating the tag that fails to
>> link. My main interest in ITK is image segmentation, so I'm hoping
>> someone
>> can help me get over this early hurdle.
>>
>>
>>
>> Many thanks in advance-
>>
>>
>>
>> Perry
>>
>>
>>
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
--
View this message in context: http://www.nabble.com/Re%3A-I%27m-New...-linking-issue-under-MS-Visual-Studio-8.-Am-using-CMake-tp23907687p23910081.html
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list