[Insight-users] Re: ITK and C++ Builder (Segmentation and GUI), how glue it together?

Emiliano Beronich emiliano at veccsa.com
Thu Apr 28 10:31:30 EDT 2005


Hi Michael and Gabriel,

We were able to run ITK on C++ Builder environment and build a whole 
application. We use ITK for processing and VTK for image display.

Here are the lessons we learned from our experience with ITK and Builder 5.

-In order to compile ITK with a Borland product, you should use Builder 
5 or the Borland free compiler. ITK doesn´t compile with Builder 6. 
Maybe in the future someone can generate a compilable version of ITK for 
Builder 6, I don´t know.

-The way to avoid access violations is to delete all the ITK classes 
before the destruction of the main form (setting 0 or NULL to the 
SmartPointer in the close event of the main form, as in 
http://public.kitware.com/pipermail/insight-users/2003-February/002572.html). 
Not doing this results in an exception of access violation when closing 
the application.

-Enabling the compiler option "Use dynamic RTL" for building the 
projects sometimes can generate errors on the release compilation. It is 
solved disabling the option. Maybe this can be due to a bug on the 
manage of templates on the DLL of STL library accompanying Builder 5.

-As Michal said, in order to compile ITK with Builder 5, you should set 
CMAKE_BUILD_TYPE = MinSizeRel (if BUILD_SHARED_LIBS = Off). In a project 
you have to set "include directories" and "link directories" manually, 
because CMake doesn't generate C++ Builder projects. You also have to 
add libraries manually to the project.

-If you enable the BUILD_SHARED_LIBS option, ITK can be compiled for 
debug, for release, etc. You should modify at hand the makefiles to 
avoid using the RTL DLLs (Use dynamic RTL = off). Eliminate the 
parameter "-tWR" from the makefile. Now we can debug the code inside of 
the itkCommon.lib. The application must see on the path the file 
itkCommon.dll and itkCommon.tds. Maybe the default behaviour of CMAKE 
should be modified to incorporate this change.

-It's recommended to install the patch for Builder 5. Some errors were 
solved after the installation of the patch.

-On the conditional defines (Directories/Conditionals tab) of the 
project maybe you need to add the following words:
STRICT
NO_WIN32_LEAN_AND_MEAN

The first is needed if you use vtk. The define STRICT avoid a conflict 
with HWND when reading "vtkWin32OpenGLRenderWindow.h".
The second if you use "shlobj.h" or "shellapi.h", but this has nothing 
to do with itk.

Regards,
Emiliano Beronich



sandarak at wp.pl wrote:
> Hi Gabriel
> 
> Yes. I was trying to get ITK and Builder to work together But with no
> final success. It would compile and as far as I remember some simple
> examples would work but others would generate Access Violation Error.
> So I'm using FLTK to make GUI. Another good thing about using FLTK is
> that are many examples of working applications which use it.
> 
> - first important thing is that you have to use C++ Builder 5.x.
> Builder 6 (as I've read in mialing list) can't compile templated code
> 
> - Compiler which comes with C++ Builder 5 is ver 5.5.0 and it won't
> compile ITK. You have to download the compiler from Borland site (it's
> free) and overwrite files from binary directory of builder with the
> ones from the compiler you downloaded (it's version 5.5.1).
> 
> - If you want to build itk, you have to use MinSizeRel flag in cmake.
> It's ( as I've read on mailng list) because of some restrictions of
> borland linker to work with projects bigger than 32 MB (or some value
> near 30MBs)
> 
> - You have to set "include directories" and "link directories"
> manually, because CMake doesn't generate C++ Builder projects.
> You also have to add libraries manually to the project
> 
> - You also have to change settings of compiler and linker in the
> project file to resemble those which Cmake uses. (But Builder will
> change them automatically after you open project, which is rather
> disastrous and I don't know how to change this behaviour)
> 
> What Can I say. Trying to get ITK work together with Builder is a waste
> of time and energy in my opinion. And you probably wont get much help
> from mailing list because ITK can be compiled using Borland Compiler but
> not using C++ builder enviroment.
> 
> If it's possible I suggest you migrate to MS Visual 6.0 and use it as
> compiler and debug tool. Use FLTK to create GUI. And VTK to visualize.
> 
> 
> Regards
> 
> Michal
> 
> 
>>Hi Michal Postrozny,
> 
> 
>>Googling I found your posting regarding C++ Builder joing ITK libraries.
>>I was wondering if I got any valuable answer from Insight-List. If so, I
>>will really appreciate if you can share the hint.
> 
> 
>>Best Regards
> 
> 
>>Gabriel
>>UBC - ECE Department
>>Vancouver, B.C. Canada
> 
> 
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 


More information about the Insight-users mailing list