[Insight-users] Error in compilation of WatershedImageFilter in a standalone project

Feng Ma mafeng at hotmail . com
Tue, 16 Sep 2003 19:10:05 -0400


Hi,

  I am working on a project which call ITK watershed library inside a C 
function. To do this, I wrote a C++ wrapper which uses 
itk::ResampleImageFilter, itk::CurvatureAnisotropicDiffusionImageFilter, 
itk::GradientMagnitudeImageFilter and itk::WatershedImageFilter. Basically 
the same operation as we saw in the watershed example. Then the main C 
function will call this c++ wrapper. The wrapper is compiled using c++ 
compiler (g++). The main function is compiled using c compiler (gcc). The 
project is finally linked using g++. I do declare the wrapper function to be 
extern "C" in order to be able to call from a C function.

  I use cmake to construct the project. However, I got the following error 
during the final link stage, related to watershed image filter:

/r2net/r2/fma/ITK/lib/InsightToolkit/libITKWrapLib.a(itkWatershed3DSeg.o): 
In function `itk::WatershedImageFilter<itk::Image<float, 3> 
 >::WatershedImageFilter(void)':
itkWatershed3DSeg.o(.itk::WatershedImageFilter<itk::Image<float, 3> 
 >::gnu.linkonce.t.(void)+0x5a7): undefined reference to 
`itk::WatershedMiniPipelineProgressCommand type_info function'
itkWatershed3DSeg.o(.itk::WatershedImageFilter<itk::Image<float, 3> 
 >::gnu.linkonce.t.(void)+0x5d9): undefined reference to 
`itk::WatershedMiniPipelineProgressCommand type_info function'
itkWatershed3DSeg.o(.itk::WatershedImageFilter<itk::Image<float, 3> 
 >::gnu.linkonce.t.(void)+0x65b): undefined reference to 
`itk::WatershedMiniPipelineProgressCommand virtual table'
/r2net/r2/fma/ITK/lib/InsightToolkit/libITKWrapLib.a(itkWatershed3DSeg.o): 
In function `itk::WatershedImageFilter<itk::Image<float, 3> 
 >::GenerateData(void)':
itkWatershed3DSeg.o(.itk::WatershedImageFilter<itk::Image<float, 3> 
 >::gnu.linkonce.t.GenerateData(void)+0x1ab): undefined reference to 
`itk::WatershedMiniPipelineProgressCommand type_info function'
collect2: ld returned 1 exit status

   If I commented out parts related to watershed, there is no error.

   If I remove the extern "C" for the wrapper, also change the caller to be 
a c++ file and compile the calling function using c++, I got the same error.

   If I build the same application inside InsightApplication tree, without 
using wrappers, I don't have any error.

  Any thoughts on this? I am thinking my situation may be a common situation 
for some users. We want to call ITK functions from some legacy code which is 
c-compatible. To use ITK library, one easy way is to write a c wrapper.

  If needed, I will post my code here. I am using CVS version of ITK. I 
could not remember the exact date I checked out, but should be after 1.2 
release. My "cvs status" shows:
===================================================================
File: itkWatershedMiniPipelineProgressCommand.cxx       Status: Needs Patch

   Working revision:    1.2
   Repository revision: 1.3     
/cvsroot/Insight/Insight/Code/Algorithms/itkWatershedMiniPipelineProgressCommand.cxx,v
   Sticky Tag:          (none)
   Sticky Date:         (none)
   Sticky Options:      (none)

  Is this a known problem and fixed in cvs already?

  Thanks a lot.

-Feng

_________________________________________________________________
Try MSN Messenger 6.0 with integrated webcam functionality! 
http://www . msnmessenger-download . com/tracking/reach_webcam