Hi Dan,<div><br></div><div>Thank you for your response. I had looked at the second option of the old thread but it is a little out dated and I was unable to make it work. One issue is that there are a ton of projects and the configuration is off on all of them. That is actually why I was playing with cmake (both settings and code) to see if I could get it to configure the projects correctly for my situation. I was able to do most of the conversion with the exception of c files being forced to CompileAsC in the settings make them incompatible with /clr.</div>
<div><br></div><div>I will probably go down the road of the first option although the project does not have the full set of functions that I would like to use.</div><div><br></div><div>Any further suggestions would be greatly appreciated or even an example in <a href="http://www.itk.org/Wiki/ITK/Examples">http://www.itk.org/Wiki/ITK/Examples</a> would be great.</div>
<div><br></div><div>Thank you again,</div><div><br></div><div>Anthony</div><div><br></div><div><br><div class="gmail_quote">On Wed, Feb 20, 2013 at 1:26 AM, Dan Mueller <span dir="ltr"><<a href="mailto:dan.muel@gmail.com" target="_blank">dan.muel@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Anthony,<br>
<div class="im"><br>
> So, does a simple solution exist?<br>
<br>
</div>There are a number of options available to you.<br>
<br>
1. Use the SimpleITK C# (.NET) wrappers:<br>
<a href="http://sourceforge.net/projects/simpleitk/files/SimpleITK/" target="_blank">http://sourceforge.net/projects/simpleitk/files/SimpleITK/</a><br>
<br>
Although the wrappers are called C#, it is a .NET assembly which can<br>
be used directly from C++\CLI.<br>
<br>
An example would be:<br>
// =========================<br>
#include "stdafx.h"<br>
#using <SimpleITKCSharpManaged.dll> // Location specified using /AI switch<br>
using namespace System;<br>
<br>
int main(array<System::String ^> ^args)<br>
{<br>
auto image = itk::simple::SimpleITK::ReadImage("C:/Temp/cthead1.png");<br>
Console::WriteLine(image);<br>
return 0;<br>
}<br>
// =========================<br>
<br>
2. It is possible to compile to ITK with the /clr switch. There are<br>
some instructions on a really old thread here:<br>
<a href="http://public.kitware.com/pipermail/insight-users/2006-October/019648.html" target="_blank">http://public.kitware.com/pipermail/insight-users/2006-October/019648.html</a><br>
<br>
The discontinued ManagedITK provided a .NET wrapper around ITK using<br>
C++\CLI. The source code may give you some inspiration for correctly<br>
setting up your Visual Studio project:<br>
<a href="http://code.google.com/p/manageditk/source/browse/trunk" target="_blank">http://code.google.com/p/manageditk/source/browse/trunk</a><br>
<br>
Essentially, ManagedITK used CMake to generate a normal C++ vcproj<br>
file, and then ran the "ConfigureProject" utility to automagically<br>
hack the vcproj file to compile ITK with /clr:<br>
<a href="http://code.google.com/p/manageditk/source/browse/trunk#trunk%2FUtilities%2FConfigureProject" target="_blank">http://code.google.com/p/manageditk/source/browse/trunk#trunk%2FUtilities%2FConfigureProject</a><br>
<a href="http://manageditk.googlecode.com/svn/trunk/FinishCMake.bat.in" target="_blank">http://manageditk.googlecode.com/svn/trunk/FinishCMake.bat.in</a><br>
<br>
3. You could use P/Invoke to access a pure unmanaged C++ DLL which<br>
encapsulates all your ITK functionality from the managed C++/CLI<br>
environment. A step-by-step guide can be found here:<br>
<a href="http://www.itk.org/Wiki/ITK/Using_ITK_from_.NET" target="_blank">http://www.itk.org/Wiki/ITK/Using_ITK_from_.NET</a><br>
<br>
I hope one of these options suits your purposes.<br>
<br>
Cheers, Dan<br>
<div><div class="h5"><br>
On 20 February 2013 15:17, Anthony Baker <<a href="mailto:anthony.ww.baker@gmail.com">anthony.ww.baker@gmail.com</a>> wrote:<br>
> I would like to use ITK on an existing project and am interested in the<br>
> simplest path to success. I am using c++\cli in visual studio. I have<br>
> incorporated OpenCV and GDAL into the project and have many classes and win<br>
> form windows incorporated.<br>
><br>
> I thought (naively) that I could treat ITK in a similar way to OpenCV. I<br>
> compiled openCV into a set of dlls. I then compiled my project with the<br>
> includes and linked against the .libs and finally included the opencv dlls<br>
> with my final deployment exe.<br>
><br>
> I tried this method with ITK but it didn't work. I was able to compile and<br>
> link by added the right headers and .lib files but when I ran the project it<br>
> immediately failed with some sort of load errors. To show how simple I<br>
> started, I only included a single header file to my existing project.<br>
><br>
> I thought maybe if I compiled the ITK project as CLR things would be better.<br>
> The upshot of that is that I was never able to even compile in that mode due<br>
> to the .c files not compiling as c++ (I tried with every effort from the<br>
> cmake side to make that happen including trying to change the cmake code -<br>
> ha).<br>
><br>
> So, does a simple solution exist? Can someone provide an example that<br>
> works?<br>
><br>
> Please help with my, now, obsession to make this work!<br>
><br>
> Many Thanks,<br>
><br>
> Anthony<br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
</blockquote></div><br></div>