<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Glad to hear the recommendation worked for you. You likely can trim that library up a bit for your needs. </div><div><br>On Nov 4, 2015, at 5:56 PM, Michael Jackson <<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>> wrote:<br><br></div><blockquote type="cite"><div>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">On the advice from Matt we stripped out the “Explicit” library code from SimpleITK and integrated it into DREAM.3D as a test and we were finally able to have multiple plugins load ITK and use ITK functionality without casting errors. Not sure what we are going to do for a long term solution but it is obvious that we were missing a cast operation somewhere.<div class=""><br class=""></div><div class="">Thanks for all the help.<br class=""><div apple-content-edited="true" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">--</div><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Mike Jackson [<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>]<br class=""><br class=""></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2015, at 4:36 PM, Michael Jackson <<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Your suspicions may be correct. We tried with a different filter (Sobel Edge) and get the following Exception from ITK:<br class=""><br class="">"Failed to execute itk::SobelEdgeDetectionImageFilter filter. Error Message returned from ITK:<br class=""> itk::ERROR: Image(0x7fb12a112f60): itk::ImageBase::CopyInformation() cannot cast PKN3itk10DataObjectE to PKN3itk9ImageBaseILj3EEE”<br class=""><br class="">Does this help diagnosing the issue?<br class=""><br class="">We have also found that if our actual application is linked against ITK then the code will execute without issues. If the application is NOT linked against ITK but instead only the plugin itself is linked against ITK then the code will fail when multiple plugins are linked against ITK.<br class=""><br class="">Again, thanks for all the help.<br class="">--<br class="">Mike Jackson [<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>]<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Nov 2, 2015, at 1:12 PM, Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov" class="">blowekamp@mail.nih.gov</a>> wrote:<br class=""><br class="">I still think it's a failing dynamic cast some place.<br class=""><br class="">You could try adding SimpleITK's Explicit library[1] which explicitly instantiates common types used in SimpleITK. Its possible having some of the Core Common classes instated in a shared library resolves the problem. The library should be fairly independent and easy to separate.<br class=""><br class="">HTH,<br class="">Brad<br class=""><br class="">[1] <a href="https://github.com/SimpleITK/SimpleITK/tree/master/Code/Explicit" class="">https://github.com/SimpleITK/SimpleITK/tree/master/Code/Explicit</a><br class=""><br class="">On Nov 2, 2015, at 12:17 PM, Michael Jackson <<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">That did not seem to help either. Any more ideas? Does ITK build some intermediate static libraries that have “managers” that load filters? I ran into an issue with our own code where we had static libraries with singleton “manager” design patterns that turned out not to work due to each library getting its own singleton instance.<br class="">--<br class="">Mike Jackson [<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>]<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Oct 30, 2015, at 4:07 PM, Matt McCormick <<a href="mailto:matt.mccormick@kitware.com" class="">matt.mccormick@kitware.com</a>> wrote:<br class=""><br class="">Thanks for the information.<br class=""><br class="">It is hard to tell, but maybe it is related to factory registration.<br class="">To test, try this:<br class=""><br class="">In the plugin CMake code, add<br class=""><br class=""> set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1)<br class=""><br class="">before<br class=""><br class=""> include(${ITK_USE_FILE})<br class=""><br class="">Then see if neither plugins work, both plugins work, and one of the<br class="">plugins works.<br class=""><br class="">HTH,<br class="">Matt<br class=""><br class="">On Fri, Oct 30, 2015 at 1:36 PM, Michael Jackson<br class=""><<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>> wrote:<br class=""><blockquote type="cite" class="">Some more data. If we create an intermediate library that links to ITK, called ITKSupport, and then have our plugins link against ITKSupport then the code executes correctly. Just another data point.<br class="">--<br class="">Michael A. Jackson<br class="">BlueQuartz Software, LLC<br class="">[e]: <a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a><br class=""><br class=""><blockquote type="cite" class="">On Oct 30, 2015, at 12:57 PM, Michael Jackson <<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>> wrote:<br class=""><br class="">Yes. Verified. Both plugins are built as part of DREAM.3D and we don’t put any extra CXX_FLAGS in any of the CMake files. We also built with VERBOSE=1 and looked at the compile commands to ensure that what we wanted was actually being used. Then we looked at the libraries themselves with otool -L to ensure they all link against libC++. Which they do.<br class=""><br class=""><br class="">--<br class="">Michael A. Jackson<br class="">BlueQuartz Software, LLC<br class="">[e]: <a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a><br class=""><br class=""><blockquote type="cite" class="">On Oct 30, 2015, at 12:05 PM, Matt McCormick <<a href="mailto:matt.mccormick@kitware.com" class="">matt.mccormick@kitware.com</a>> wrote:<br class=""><br class="">Hi Michael,<br class=""><br class="">Sorry to be redundant, and just to be sure: are both A.plugin and<br class="">B.plugin built with the same C++ standard library, OSX deployment<br class="">target, and C++ standard?<br class=""><br class="">Thanks,<br class="">Matt<br class=""><br class="">On Fri, Oct 30, 2015 at 11:35 AM, Michael Jackson<br class=""><<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>> wrote:<br class=""><blockquote type="cite" class=""><br class=""><br class=""><blockquote type="cite" class="">On Oct 29, 2015, at 11:40 AM, Matt McCormick <<a href="mailto:matt.mccormick@kitware.com" class="">matt.mccormick@kitware.com</a>> wrote:<br class=""><br class="">On Thu, Oct 29, 2015 at 10:00 AM, Michael Jackson<br class=""><<a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a>> wrote:<br class=""><blockquote type="cite" class="">We also ran an experiment where we moved the ITK Dependency from just the<br class="">plugin down into one of our lower level libraries. So now we have the plugin<br class="">dependent on a lower level library which then is dependent on the ITK<br class="">Libraries. Now the code seems to execute and produce results. This was on OS<br class="">X 10.9 and 10.10. So it seems that there is some odd issue with loading the<br class="">ITK libraries through a plugin mechanism? Does ITK need the “-fPIC” added to<br class="">the list of compile commands?<br class=""></blockquote><br class="">If ITK is built in a plugin as shared libraries, then it will already<br class="">be built with -fPIC.<br class=""><br class=""><br class=""><blockquote type="cite" class="">Qt is actually built WITHOUT C++11 support but still links against libc++.<br class="">They (the Qt Devs) set the OS X Min Deployment Version to 10.7. I have no<br class="">idea what that triggers or not.<br class=""></blockquote><br class="">All code should be built with the same C++ standard and OSX deployment<br class="">target. When building ITK and related code, set<br class="">CMAKE_OSX_DEPLOYMENT_TARGET [1] to 10.7 to ensure all binaries are<br class="">using consistent libraries.<br class=""><br class="">HTH,<br class="">Matt<br class=""><br class="">[1] <a href="https://cmake.org/cmake/help/v3.3/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html" class="">https://cmake.org/cmake/help/v3.3/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html</a><br class=""></blockquote><br class="">Matt,<br class="">We have verified that ALL dependent libraries are built with libC++, 10.7 as the min deployment, C++11 enabled. This goes for Boost, HDF5, Eigen, ITK, and Qt 5.5.1. We still have the issue. We can also reproduce that if we move the dependency to a lower level then the issue goes away. So it would seem that there is a problem with multiple plugins being dependent on the same External library. in this case it is ITK. I’ll try to diagram below.<br class="">## Failure Mode ##<br class="">A.plugin depends on ITK<br class="">A.plugin depends on SIMPlib.<br class=""><br class="">B.plugin depends on ITK<br class="">B.plugin depends on SIMPlib.<br class=""><br class="">B.plugin will fail to execute properly.<br class=""><br class="">## Success Mode ##<br class="">A.plugin depends on SIMPlib.<br class="">SIMPlib depends on ITK<br class=""><br class="">B.plugin depends on SIMPlib.<br class="">SIMPlib depends on ITK<br class=""><br class="">The DREAM.3D filters both execute properly and give the proper output.<br class=""><br class="">--<br class="">Michael A. Jackson<br class="">BlueQuartz Software, LLC<br class="">[e]: <a href="mailto:mike.jackson@bluequartz.net" class="">mike.jackson@bluequartz.net</a><br class="">_____________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at<br class=""><a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Kitware offers ITK Training Courses, for more information visit:<br class=""><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br class=""><br class="">Please keep messages on-topic and check the ITK FAQ at:<br class=""><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a><br class=""></blockquote></blockquote><br class=""></blockquote><br class=""></blockquote></blockquote><br class="">_____________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at<br class=""><a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Kitware offers ITK Training Courses, for more information visit:<br class=""><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br class=""><br class="">Please keep messages on-topic and check the ITK FAQ at:<br class=""><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a><br class=""></blockquote><br class=""></blockquote><br class=""></div></blockquote></div><br class=""></div></div></blockquote><blockquote type="cite"><div><span>_____________________________________</span><br><span>Powered by <a href="http://www.kitware.com">www.kitware.com</a></span><br><span></span><br><span>Visit other Kitware open-source projects at</span><br><span><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br><span></span><br><span>Kitware offers ITK Training Courses, for more information visit:</span><br><span><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a></span><br><span></span><br><span>Please keep messages on-topic and check the ITK FAQ at:</span><br><span><a href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br><span><a href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/mailman/listinfo/insight-users</a></span><br></div></blockquote></body></html>