[Insight-users] ITK and C++\CLI
Bill Lorensen
bill.lorensen at gmail.com
Wed Feb 20 10:29:18 EST 2013
In the long run, I think you are better off using cmake.
On Wed, Feb 20, 2013 at 9:29 AM, Anthony Baker
<anthony.ww.baker at gmail.com> wrote:
> Hi Dan,
>
> 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.
>
> 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.
>
> Any further suggestions would be greatly appreciated or even an example in
> http://www.itk.org/Wiki/ITK/Examples would be great.
>
> Thank you again,
>
> Anthony
>
>
> On Wed, Feb 20, 2013 at 1:26 AM, Dan Mueller <dan.muel at gmail.com> wrote:
>>
>> Hi Anthony,
>>
>> > So, does a simple solution exist?
>>
>> There are a number of options available to you.
>>
>> 1. Use the SimpleITK C# (.NET) wrappers:
>> http://sourceforge.net/projects/simpleitk/files/SimpleITK/
>>
>> Although the wrappers are called C#, it is a .NET assembly which can
>> be used directly from C++\CLI.
>>
>> An example would be:
>> // =========================
>> #include "stdafx.h"
>> #using <SimpleITKCSharpManaged.dll> // Location specified using /AI switch
>> using namespace System;
>>
>> int main(array<System::String ^> ^args)
>> {
>> auto image = itk::simple::SimpleITK::ReadImage("C:/Temp/cthead1.png");
>> Console::WriteLine(image);
>> return 0;
>> }
>> // =========================
>>
>> 2. It is possible to compile to ITK with the /clr switch. There are
>> some instructions on a really old thread here:
>> http://public.kitware.com/pipermail/insight-users/2006-October/019648.html
>>
>> The discontinued ManagedITK provided a .NET wrapper around ITK using
>> C++\CLI. The source code may give you some inspiration for correctly
>> setting up your Visual Studio project:
>> http://code.google.com/p/manageditk/source/browse/trunk
>>
>> Essentially, ManagedITK used CMake to generate a normal C++ vcproj
>> file, and then ran the "ConfigureProject" utility to automagically
>> hack the vcproj file to compile ITK with /clr:
>>
>> http://code.google.com/p/manageditk/source/browse/trunk#trunk%2FUtilities%2FConfigureProject
>> http://manageditk.googlecode.com/svn/trunk/FinishCMake.bat.in
>>
>> 3. You could use P/Invoke to access a pure unmanaged C++ DLL which
>> encapsulates all your ITK functionality from the managed C++/CLI
>> environment. A step-by-step guide can be found here:
>> http://www.itk.org/Wiki/ITK/Using_ITK_from_.NET
>>
>> I hope one of these options suits your purposes.
>>
>> Cheers, Dan
>>
>> On 20 February 2013 15:17, Anthony Baker <anthony.ww.baker at gmail.com>
>> wrote:
>> > I would like to use ITK on an existing project and am interested in the
>> > simplest path to success. I am using c++\cli in visual studio. I have
>> > incorporated OpenCV and GDAL into the project and have many classes and
>> > win
>> > form windows incorporated.
>> >
>> > I thought (naively) that I could treat ITK in a similar way to OpenCV.
>> > I
>> > compiled openCV into a set of dlls. I then compiled my project with the
>> > includes and linked against the .libs and finally included the opencv
>> > dlls
>> > with my final deployment exe.
>> >
>> > I tried this method with ITK but it didn't work. I was able to compile
>> > and
>> > link by added the right headers and .lib files but when I ran the
>> > project it
>> > immediately failed with some sort of load errors. To show how simple I
>> > started, I only included a single header file to my existing project.
>> >
>> > I thought maybe if I compiled the ITK project as CLR things would be
>> > better.
>> > The upshot of that is that I was never able to even compile in that mode
>> > due
>> > to the .c files not compiling as c++ (I tried with every effort from the
>> > cmake side to make that happen including trying to change the cmake code
>> > -
>> > ha).
>> >
>> > So, does a simple solution exist? Can someone provide an example that
>> > works?
>> >
>> > Please help with my, now, obsession to make this work!
>> >
>> > Many Thanks,
>> >
>> > Anthony
>> >
>> > _____________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Kitware offers ITK Training Courses, for more information visit:
>> > http://www.kitware.com/products/protraining.php
>> >
>> > Please keep messages on-topic and check the ITK FAQ at:
>> > http://www.itk.org/Wiki/ITK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.itk.org/mailman/listinfo/insight-users
>> >
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
--
Unpaid intern in BillsBasement at noware dot com
More information about the Insight-users
mailing list