[Insight-users] Linking error

Luis Ibanez luis.ibanez at kitware.com
Sun May 22 18:57:02 EDT 2011


Hi Dora,


Short Answer:

In your CMakeList.txt file you are missing the library

                          ITKAlgorithms

from your command

            TARGET_LINK_LIBRARIES

--------------------------------------------------------

Long Answer:

Whenever you run into a missing symbol error,

you should follow this procedure:


1) Grep the ITK source tree for that symbol.

In this case:

   cd src/Insight
   grep -r WatershedMiniPipelineProgressCommand  *

you will find:

Algorithms/itkWatershedMiniPipelineProgressCommand.h
Algorithms/itkWatershedMiniPipelineProgressCommand.cxx


2) Go to that directory:

              cd   Insight/Code/Algorithms

3) Open the CMakeLists.txt file with a text editor

4) Search for the file with the symbol,
     in this case

itkWatershedMiniPipelineProgressCommand

you will find it in line 2 in the expression:


ADD_LIBRARY(ITKAlgorithms
  itkWatershedMiniPipelineProgressCommand.cxx
  itkBioCellBase.cxx
  itkBioCellularAggregateBase.cxx
  itkBioGenome.cxx
  itkBioGene.cxx
  itkBioGeneNetwork.cxx
)

Which means that the class

itkWatershedMiniPipelineProgressCommand

is being packed in the library:

              "ITKAlgorithms"


5) Therefore,
     Now you will know that the symbol is missing,
     because you are not linking to the library:

                       ITKAlgorithms


---

You can apply this same procedure to deal with
most cases of    "unresolved external symbol"



     Luis



-------------------------------------
On Sun, May 22, 2011 at 5:29 AM, Dora Szasz <dora.szasz at yahoo.com> wrote:
> Now, I've tried also to Build the example: WatershedSegmentation1.cxx from
> Segmentation folder of ITK, and I have the same linking error:
> 1>WatershedSegmentation1.obj : error LNK2001: unresolved external symbol
> "protected: virtual void __thiscall
> itk::WatershedMiniPipelineProgressCommand::PrintSelf(class
> std::basic_ostream<char,struct std::char_traits<char> > &,class
> itk::Indent)const "
> (?PrintSelf at WatershedMiniPipelineProgressCommand@itk@@MBEXAAV?$basic_ostream at DU?$char_traits at D@std@@@std@@VIndent at 2@@Z)
> I have also built in the same way the examples
> ConnectedThresholdImageFilter.cxx and ConfidenceConnected.cxx and everything
> worked perfectly. I don't know why the linking error appear for some
> examples.
> Thanks!
>
> ________________________________
> From: Dora Szasz <dora.szasz at yahoo.com>
> To: "insight-users at itk.org" <insight-users at itk.org>
> Sent: Sunday, May 22, 2011 12:47 AM
> Subject: Linking error
>
> Hello!
> I am trying to build the
> example: http://www.insight-journal.org/browse/publication/146 . I used
> cmake and visual studio to build the example, but when I'm trying to build
> it the following error appeared: 1>ImageExt.obj : error LNK2019: unresolved
> external symbol "public: class vtkImageData * __thiscall
> vtkKWImage::GetVTKImage(void)"
> (?GetVTKImage at vtkKWImage@@QAEPAVvtkImageData@@XZ) referenced in function
> __catch$_main$0
> This is the CMakeLists.txt:
> cmake_minimum_required(VERSION 2.6)
> PROJECT (ImageExt)
> FIND_PACKAGE( ITK )
> IF ( ITK_FOUND )
> INCLUDE( ${ITK_USE_FILE})
> ENDIF( ITK_FOUND )
> FIND_PACKAGE (VTK)
> IF (VTK_FOUND)
> INCLUDE ( ${USE_VTK_FILE})
> ENDIF (VTK_FOUND)
> INCLUDE_DIRECTORIES (${ImageExt_SOURCE_DIR})
> ADD_EXECUTABLE( ImageExt ImageExt.cxx )
> TARGET_LINK_LIBRARIES (ImageExt ITKBasicFilters ITKCommon ITKIO
> vtkRendering vtkGraphics vtkHybrid vtkImaging vtkIO vtkFiltering vtkCommon)
> I don't know how to solve this problem. Thanks!
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.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
>
>


More information about the Insight-users mailing list