<br>Hi Matt,<br><br>I managed to replicate the problem that you<br>are reporting.<br><br>It turned out that the problem is that you are<br>probably building ITK with Static Libraries.<br><br>In order to use loadable factories, you must<br>
ITK with shared libraries. Please set to ON<br>the CMake variable:  BUILD_SHARED_LIBS.<br><br><br>The segmentation fault that you are observing<br>is the result of the call:<br><br>itkObjectFactoryBase.cxx:513:<br><br>DynamicLoader::CloseLibrary( static_cast&lt; LibHandle &gt;( *lib ) );<br>
<br><br>That closes the shared library of your plugin<br>when the executable is terminating.<br><br>If you build ITK as a static library, then the<br>ITK libs are included in the share library of<br>your plugin, and when this instruction above<br>
close the library of the plugin, you also lose<br>the stack of the base ObjectFactoryBase.<br><br>I have now pushed to github a modified <br>version of your master branch. <br><br><a href="https://github.com/luisibanez/visualisation/commits/master">https://github.com/luisibanez/visualisation/commits/master</a><br>
<br>That version replicates the problem when I link to an<br>ITK that is built using Static libraries, and works fine <br>when I link to an ITK built with Shared libraries.<br><br><br>      Regards,<br><br><br>            Luis<br>
<br><br>----------------------------------------------------<br><div class="gmail_quote">On Sun, Nov 21, 2010 at 11:58 AM, Luis Ibanez <span dir="ltr">&lt;<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi Matt,<br><br>Thanks for the detailed description of what you are doing,<br>and for sharing the code in github.<br>
<br>I have now cloned and built your project <br>and made some minor modifications.<br><br>It would seem that you have found a bug in ITK.<br>
<br>The segmentation fault seem to happen at the moment<br>of destroying all the registered factories...<br><br>I&#39;m still tracking this in gdb....<br><br><br>      Luis<br><br><br>--------------------------------------------------------------<div>
<div></div><div class="h5"><br>
<div class="gmail_quote">On Thu, Nov 18, 2010 at 8:59 PM, Matthew Gibb <span dir="ltr">&lt;<a href="mailto:matthew.gibb@dtc.ox.ac.uk" target="_blank">matthew.gibb@dtc.ox.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Dear Dr. Ibanez,<div><br></div><div>My name is Matthew Gibb and I&#39;m currently studying for a DPhil at Oxford University in cardiac imaging, modelling and simulation. I&#39;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!</div>



<div><br></div><div>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&#39;t quite get working is the plugin mechanism, so that ITK programs load the factory at runtime. I&#39;ve followed the instructions here:</div>



<div><br></div><div><a href="http://www.itk.org/Wiki/Plugin_IO_mechanisms" target="_blank">http://www.itk.org/Wiki/Plugin_IO_mechanisms</a></div><div><br></div><div>and my code is available here:</div><div><br></div><div>

<a href="http://github.com/mattgibb/visualisation" target="_blank">http://github.com/mattgibb/visualisation</a></div>

<div><br></div><div>An example of the vox format is as follows:</div><div><br></div><div><font face="&#39;courier new&#39;, monospace">2 2 2</font></div><div><font face="&#39;courier new&#39;, monospace">3.0 2.0 5.0</font></div>



<div><font face="&#39;courier new&#39;, monospace">0</font></div><div><font face="&#39;courier new&#39;, monospace">0</font></div><div><font face="&#39;courier new&#39;, monospace">1</font></div>

<div><font face="&#39;courier new&#39;, monospace">1</font></div><div><font face="&#39;courier new&#39;, monospace">0</font></div><div><font face="&#39;courier new&#39;, monospace">0</font></div>

<div><font face="&#39;courier new&#39;, monospace">1</font></div><div><font face="&#39;courier new&#39;, monospace">1</font></div><div><br></div><div>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.</div>



<div><br></div><div>When I change into the converters/build/bin directory and run &#39;./convert_image test.vox test2.vox&#39;, everything works fine. However, if i do</div><div><br></div><div><font face="&#39;courier new&#39;, monospace">export ITK_AUTOLOAD_PATH=&quot;/path/to/build/lib&quot;</font></div>



<div><br></div><div>and comment out the explicit registration line in convert_image.cpp</div><div><br></div><div><font face="&#39;courier new&#39;, monospace">// itk::ObjectFactoryBase::RegisterFactory( itk::VoxImageIOFactory::New() );</font></div>



<div><br></div><div>I get the following error at runtime:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">Reading...Error ImageIO factory did not return an ImageIOBase: VoxImageIO</font></div>



<div><font face="&#39;courier new&#39;, monospace">zsh: segmentation fault  ./convert_image test.vox test2.vox</font></div></div><div><br></div><div>I&#39;m really stuck, as I think I&#39;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&#39;t work :-(</div>



<div><br></div><div>Any help or advice you could offer would be greatly appreciated.</div><div><br></div><div>Many thanks,</div><div><br></div><div>Matt Gibb.</div>
</blockquote></div><br>
</div></div></blockquote></div><br>