Instructions for ITK Cygwin build Jacob Bedrossian jacob.bedrossian@gmail.com MIMvista corp. 6/1/2007 ITK does not appear to configure correctly for build under cygwin. This file attempts to document the changes made to the code in an effort to complete the build. I in no way guarantee these changes will be sufficient (perhaps a different workstation will behave differently) or necessary (there is almost definitely better ways to resolve the issues here). This file is most readable fullscreen with wordwrap off. IMPORTANT: If you intend to wrap itk, do not bother running the first set of instructions seperately from the wrapping instructions. Installing CableSwig requires re-running ccmake, which will undo the configuration changes that need to be made in order to build itk. Thus, should you require a java wrapping, download itk and CableSwig at the same time and insert the "Building ITK" instructions into the Wrapping instructions between steps 2 and 3 (of course, ignore step 1 of the "Building ITK" instructions). ANOTHER DISCLAIMER: Some of the changes, especially in the wrapping instructions, may jeopardize the proper operation of the wrappings. THIS HAS NOT BEEN TESTED. Building ITK 1. Download the itk sources and install cmake from the cygwin setup.exe application. 2. For some reason Insight suggests an 'out of source build' in a sibling directory to the code. It should work either way, but I did as recommended. In cygwin, cd into the directory you want to put the binaries in and execute the command: 'ccmake ' 3. Insight recommends disabling the options to build the tests, examples and shared libs. Make sure the compiler is defaulted to gcc and g++ etc and the make program is make.exe in the cygwin bin. Configure, ignore the warning and generate. If no option to generate is given after the first configure, configure again and generate. This produces makefiles for the entire source tree. 4. Insight claims running make in the source directory will be sufficient to build itk, but this is not true. In the subsequent steps, should you attempt a make on any portion of the code, be sure to write the error reports into a text file to be read later (use wordpad, not a cygwin editor) using a command such as 'make 2> errlog'. 5. The first changes to should make are in the file \Utilities\itksys\Configure.hxx. Verify that the first block of #define statements looks like this: /* Whether kwsys namespace is "kwsys". */ #define itksys_NAME_IS_KWSYS 0 /* Whether ANSI C++ stream headers are to be used. */ #define itksys_IOS_USE_ANSI 1 /* Whether ANSI C++ streams are in std namespace. */ #define itksys_IOS_HAVE_STD 1 /* Whether ANSI C++ header is to be used. */ #define itksys_IOS_USE_SSTREAM 1 /* Whether old C++ header is to be used. */ #define itksys_IOS_USE_STRSTREAM_H 0 /* Whether old C++ header is to be used. */ #define itksys_IOS_USE_STRSTREA_H 0 /* Whether STL is in std namespace. */ #define itksys_STL_HAVE_STD 1 /* Whether the STL string has operator<< for ostream. */ #define itksys_STL_STRING_HAVE_OSTREAM 1 /* Whether the STL string has operator>> for istream. */ #define itksys_STL_STRING_HAVE_ISTREAM 1 /* Whether the STL string has operator!= for char*. */ #define itksys_STL_STRING_HAVE_NEQ_CHAR 1 7. After these changes, should you attempt a make on the entire source tree you should get to around 55% before stopping. The next set of errors are thrown by the \Utilities\vxl makefiles so you should cd there and only attempt to make there for now. 8. Like itksys, vxl is not configured properly. make the following change to \Utilities\vxl\vcl\vcl_config_compiler.h: Find and verify the #define statements: #define VCL_DEFINE_SPECIALIZATION template <> #define VCL_NEED_FRIEND_FOR_TEMPLATE_OVERLOAD 0 Wrapping installation 0. 1. retrieve CableSwig from the cvs repository into the /Utilities directory of ITK. Do this with the command: 'cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/CableSwig checkout CableSwig' it will take a long while. 2. run ccmake on the entire itk directory. Should you want to run make at any time, be sure to run in the CableSwig directory first (it won't work unless you finish the steps though!). Here are some tips on getting ccmake to run here: Set BUILD_SHARED_LIBS ON (make some other changes to the settings of ccmake I lost and could not recover due to power outage!) 3. Locate the file \Utilities\CableSwig\SWIG\NEW. Copy the contents into a text file (.txt extension) and delete the original. 4. Locate the file \Utilities\CableSwig\SWIG\Source\Include\swigconfig.h and add the line #define HAVE_BOOL 1 5. Locate the file \Utilities\CableSwig\GCC\include\libiberty.h Remove all the DECL_ in the vasprintf etc statements #if Change the followings lines: #if !HAVE_DECL_ASPRINTF to #if !HAVE_ASPRINTF #if !HAVE_DECL_VASPRINTF to #if !HAVE_VASPRINTF Comment the lines (NOT CONTIGUOUS!) extern const char *strerrno PARAMS ((int)); extern int strtoerrno PARAMS ((const char *)); extern const char *strsigno PARAMS ((int)); extern int strtosigno PARAMS ((const char *)); Add #include to the include block 6. Locate the file \Utilities\CableSwig\GCC\libiberty\config.h. Find and verify this statement: #define HAVE_SYS_ERRLIST 1 7.Locate the file \Utilities\CableSwig\GCC\gcc\auto-host.h. Find and verify the following lines (NOT CONTIGUOUS!): #define HAVE_CLOCK_T 1 #define HAVE_STRUCT_TMS 1 8. Locate the file \Utilities\CableSwig\GCC\gcc\dirent.h and comment the line typedef struct DIR_s DIR; 9. Locate the file \Utilities\CableSwig\GCC\gcc\dirent.c. Make sure the structs dirent and DIR_s are in dirent.h instead of dirent.c. 10. change the name of DIR_s to DIR. 11. In dirent.c replace the _finddata_t structs with dirent structs. 12. In dirent.c Change the expressions 'data.name' to 'data.d_name' 13. Locate the file \Utilities\CableSwig\GCC_XML\gxsys\Configure.hxx and verify the first block of #define statements matches /* Whether kwsys namespace is "kwsys". */ #define gxsys_NAME_IS_KWSYS 0 /* Whether ANSI C++ stream headers are to be used. */ #define gxsys_IOS_USE_ANSI 1 /* Whether ANSI C++ streams are in std namespace. */ #define gxsys_IOS_HAVE_STD 1 /* Whether ANSI C++ header is to be used. */ #define gxsys_IOS_USE_SSTREAM 1 /* Whether old C++ header is to be used. */ #define gxsys_IOS_USE_STRSTREAM_H 0 /* Whether old C++ header is to be used. */ #define gxsys_IOS_USE_STRSTREA_H 0 /* Whether STL is in std namespace. */ #define gxsys_STL_HAVE_STD 1 /* Whether the STL string has operator<< for ostream. */ #define gxsys_STL_STRING_HAVE_OSTREAM 1 /* Whether the STL string has operator>> for istream. */ #define gxsys_STL_STRING_HAVE_ISTREAM 1 /* Whether the STL string has operator!= for char*. */ #define gxsys_STL_STRING_HAVE_NEQ_CHAR 1 Run 'make' on the entire Insight directory. This will likely take as long as an hour or more, since a full build is done followed by CableSwig's wrapping of itk.