[Insight-users] Compiler Settings for using ITK in a VS2005 CLR
project
Mike Feur
mikefeur_02 at yahoo.com
Mon Apr 24 22:25:39 EDT 2006
Hi Tom,
Thanks for the reply. My plan is to write simple reference classes to wrap the unmanaged (itk) code. This should work just fine for incorporating unmanaged C++ code. For instance:
//****Managed wrapper class*****
public ref class MikeWrapper
{
public:
MikeWrapper(Int32 initial);
void PrintValue();
private:
MikeClass<int> *pMike;
//**Unmanaged C++ class****
template<typename T>
class MikeClass
{
public:
MikeClass(T value) {
myvec.push_back(value);
}
void PrintValue(){
std::cout<< myvec[0] << std::endl;
}
private:
std::vector<T> myvec;
};
//********************
At this point, the GUI can be written in a CLR language ( (C++/CLI, C#) and just access the wrapper class.
My tripping point is the compiler settings. The header for the unmanaged class calls itkImage.h and thus needs to have the correct ITK compiler settings, include directories and libraries. I can't use CMake unfortunately because it only sets up normal unmanaged C++ projects. John Biddiscombe posted some tips back in 2004 on how to do this in this list, but I can't seem to make it work.
Thanks for reading again.
Thomas Lambertz <thomas at hexerei-software.de> wrote: Hello Mike,
the difference between C++/CLI and conventional unmanaged C++ is much
more than only a compilerstep. For example there are no raw-pointer in
CLI and there are many other types that have changed. So it doesnt work
to set up a project for CLI by only changing some parameters in CMake.
From my point of view there´s no way to compile ITK as CLI without
rewriting nearly the complete code (but i am prepared to learn).
Resulting performance may be another contraindication.
Have you considered a mixedmode application ? I have approached it that
way. My GUI runs as a CLI-app while access to ITK is encapsulated in an
unmanaged DLL (you have to spent some attention on memory-management).
Needs some work on a wrapper but the benefits of the new gui-handling
may pay of for you.
Statically linking the (conventional) ITK library against a mixedmode
application by using "#pragma (un)managed" and some marshalling may also
work.I am sure there are more suitable solutions...
Regards,
Tom
Mike Feur wrote:
> Hello,
>
> I am trying to create a Common Language Runtime C++/CLI project that
> includes ITK code in Visual Studio 2005.
>
> There is no Cmake file for me to use. I have tried manually copying
> over all the include directories from a Cmake created ITK project. I
> am getting linker errors such as
>
> "error LNK2001: unresolved external symbol "public: virtual void
> __thiscall itk::EventObject::Print(class std::basic_ostream< ....."
>
> I tried including the appropriate lib files by adding the
> "...\InsightBin\bin\debug" directory to the "Configuration
> Properties\Linker\General\Additional Library Directories" dialog box
> in the Property Pages for the Solution, but still no luck.
>
>
> Any suggestions or instructions of how to integrate ITK into a CLR
> solution?
>
> Best of all would be a Cmake file to use, similar to the one
> available for MFC.
>
>
> Thanks for taking the time to read this.
>
t
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060424/66a74c4a/attachment.htm
More information about the Insight-users
mailing list