[Insight-users] IO Plugins

Luis Ibanez luis.ibanez at kitware.com
Sun Nov 21 13:45:22 EST 2010


Hi Matt,

I managed to replicate the problem that you
are reporting.

It turned out that the problem is that you are
probably building ITK with Static Libraries.

In order to use loadable factories, you must
ITK with shared libraries. Please set to ON
the CMake variable:  BUILD_SHARED_LIBS.


The segmentation fault that you are observing
is the result of the call:

itkObjectFactoryBase.cxx:513:

DynamicLoader::CloseLibrary( static_cast< LibHandle >( *lib ) );


That closes the shared library of your plugin
when the executable is terminating.

If you build ITK as a static library, then the
ITK libs are included in the share library of
your plugin, and when this instruction above
close the library of the plugin, you also lose
the stack of the base ObjectFactoryBase.

I have now pushed to github a modified
version of your master branch.

https://github.com/luisibanez/visualisation/commits/master

That version replicates the problem when I link to an
ITK that is built using Static libraries, and works fine
when I link to an ITK built with Shared libraries.


      Regards,


            Luis


----------------------------------------------------
On Sun, Nov 21, 2010 at 11:58 AM, Luis Ibanez <luis.ibanez at kitware.com>wrote:

> Hi Matt,
>
> Thanks for the detailed description of what you are doing,
> and for sharing the code in github.
>
> I have now cloned and built your project
> and made some minor modifications.
>
> It would seem that you have found a bug in ITK.
>
> The segmentation fault seem to happen at the moment
> of destroying all the registered factories...
>
> I'm still tracking this in gdb....
>
>
>       Luis
>
>
> --------------------------------------------------------------
>
> On Thu, Nov 18, 2010 at 8:59 PM, Matthew Gibb <matthew.gibb at dtc.ox.ac.uk>wrote:
>
>> Dear Dr. Ibanez,
>>
>> My name is Matthew Gibb and I'm currently studying for a DPhil at Oxford
>> University in cardiac imaging, modelling and simulation. I've been working
>> on a small set of tools as part of a talk to introduce my Computational
>> Biology group to ITK, VTK and ParaView, which are all awesome by the way!
>>
>> The tools are intended to reduce the barrier to entry for the use of
>> Kitware products. I have successfully created an image IO class and
>> associated factory for .vox files, a format that the meshing package
>> Tarantula uses (our group generates most of its meshes with Tarantula). The
>> last thing I can't quite get working is the plugin mechanism, so that ITK
>> programs load the factory at runtime. I've followed the instructions here:
>>
>> http://www.itk.org/Wiki/Plugin_IO_mechanisms
>>
>> and my code is available here:
>>
>> http://github.com/mattgibb/visualisation
>>
>> An example of the vox format is as follows:
>>
>> 2 2 2
>> 3.0 2.0 5.0
>> 0
>> 0
>> 1
>> 1
>> 0
>> 0
>> 1
>> 1
>>
>> The first line is the number of voxels in each dimension, and the second
>> the spacing. After that, each line is a boolean value for each voxel.
>>
>> When I change into the converters/build/bin directory and run
>> './convert_image test.vox test2.vox', everything works fine. However, if i
>> do
>>
>> export ITK_AUTOLOAD_PATH="/path/to/build/lib"
>>
>> and comment out the explicit registration line in convert_image.cpp
>>
>> // itk::ObjectFactoryBase::RegisterFactory( itk::VoxImageIOFactory::New()
>> );
>>
>> I get the following error at runtime:
>>
>> Reading...Error ImageIO factory did not return an ImageIOBase: VoxImageIO
>> zsh: segmentation fault  ./convert_image test.vox test2.vox
>>
>> I'm really stuck, as I think I've followed the instructions to the letter
>> and have no idea how to proceed. I promised the group they could use this
>> for all their ITK-based programs, but it doesn't work :-(
>>
>> Any help or advice you could offer would be greatly appreciated.
>>
>> Many thanks,
>>
>> Matt Gibb.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101121/916a3f45/attachment.htm>


More information about the Insight-users mailing list