[Insight-users] Linux compilation question

Luis Ibanez luis . ibanez at kitware . com
Tue, 03 Sep 2002 15:32:13 -0400


Hi Bill,

We have seen this problem before.
This is due to an incorrect ordering of inclusion
of header files.


What happens is that X11 defines a "Region" type in

    /usr/X11R6/include/X11/Xutil.h:  line 238:

and ITK also has defined an "itk::Region" class.

When the file "Xutil.h" got included before of the
itkRegion header the internal use of "Region" becomes
ambiguous. The compiler complains about the redefinition
of the type.

This problem illustrates nicely what namespaces are
designed to prevent. All X11 type should be in a
"X11::" namespace in order to prevent this type of
name collision with other packages.  In this scenario,
the type should be named X11::Region and there will be
no confusion with itk::Region.


The solution is to modify the order in which the
heades are included in IViewBase.cxx. What is difficult
about this is that IViewBase is generated by "fluid"
the FLTK GUI editor.  It is then necessary to identify
where in the GUI the files are used and switch the order
of the widgets that are invoking this includes.

What version of ITK are you using ?

It may be something that has already been fixed.


Please let us know,

Thanks


Luis



============================================

Bill Oliver wrote:
> 
> Hi!  I have just joined the mailing list, so if this
> has been discussed, please forgive me.
> 
> I am trying to compile ITK on a Linux box.  Most of the
> preliminaries have compiled OK, with the exception of some
> CABLE problems that have to do with downloading with CVS
> rather than compiling per se.
> 
> Things seemed to go OK for quite awhile but I have run
> into the following error:
> 
> 
> 
> -----> Begin stderr output
> 
> .... crunch crunch crunch...

> -I/home/oliver/src/Insight_build/Auxiliary/MetaImage/IView
> -D_PTHREADS  -I/usr/X11R6/include -c
> /home/oliver/src/Insight_build/Auxiliary/MetaImage/IView/IViewGUIBase.cxx
> -o IViewGUIBase.o
> 
> In file included from /usr/local/include/FL/x.H:45,
>                  from /usr/local/include/FL/Fl_Image.H:29,
> 		 from /usr/local/include/FL/Fl_Menu_Item.H:30,
> 		from /usr/local/include/FL/Fl_Menu_.H:32,
> 		from /usr/local/include/FL/Fl_Menu_Bar.H:29,
> 		from /home/oliver/src/Insight_build/Auxiliary/MetaImage/IView/IViewGUIBase.h:9,
> 		from /home/oliver/src/Insight_build/Auxiliary/MetaImage/IView/IViewGUIBase.cxx:3:
> 
> /usr/X11R6/include/X11/Xutil.h:363: use of `Region' is ambiguous
> /usr/X11R6/include/X11/Xutil.h:238:   first declared as `typedef struct
> _XRegion *Region' here
> /home/oliver/src/Insight/Code/Common/itkRegion.h:57:   also declared as `class itk::Region' here
> /usr/X11R6/include/X11/Xutil.h:363: `Region' denotes an ambiguous type
> /usr/X11R6/include/X11/Xutil.h:363: confused by earlier errors, bailing out
> make[7]: *** [IViewGUIBase.o] Error 1
> make[6]: *** [default_target] Error 2
> make[5]: *** [default_target_IView] Error 2
> make[4]: *** [default_target] Error 2
> make[3]: *** [default_target_MetaImage] Error 2
> make[2]: *** [default_target] Error 2
> make[1]: *** [default_target_Auxiliary] Error 2
> make: *** [default_target] Error 2
> 
> 
> So, I have a namespace conflict.  What's a mother to do?
> 
> Is there a g++ option for ignoring this?
> 
> Any help would be appreciated!
> 
> 
> Config:
> 
> OS: Mandrake 8.2, kernel 2.4.18-6mdk
> Hardware: Compaq 1215US laptop,
>           320MB RAM,
>           786MB on disk as swap,
>           996MHz AMD cpu,
> 
> gcc version 2.96
> 
> 
> 
> Thanks,
> 
> 
> billo
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>