Personal tools
You are here: Home cmgui Wiki Peter's notes on building cmgui
Views
Peter's notes on building cmgui copied.
FrontPage >> Building cmgui on win32 >>

Peter's notes on building cmgui

last edited 1 year ago by blackett

This is the process I followed for getting cmgui to compile on a windows machine. Note that cmgui is usually developed on a linux machine.

Compiling cmgui on a windows machine

  • Step 1: Install Cygwin to provide a linux like environment

    To install Cygwin you will need to have administrator privileges on your machine. See Installing Cygwin for more info on how to do this.

  • Step 2: Create a short cut on the desktop to the Cygwin bash shell

    This shortcut will be used a lot as you are going to be using the bash shell a fair bit.

  • Step 3: Create a directory for cmiss root where the code and libraries will be placed

    I opened up a shell and created my cmiss root in the default home directory (ie in /cygdrive/n on my machine):

       mkdir cmiss
    

  • Step 4: Set up a .bash_profile file to set all your environmental variables up every time you start up a shell

    An easy way to setup your .bash_profile is to start up a cygwin bash shell and then type:: xemacs .bash_profile

    Now add the following lines to this file and then save:

       export CMISS_ROOT=/cygdrive/n/cmiss
       export SYSNAME=win32
    

    Note you will set CMISS_ROOT to be the appropriate directory on your system. Exit xemacs, close your shell script and restart your shell. Check the environmental variables have been set up by typing env | grep CMISS_ROOT

    You should see a line telling you that CMISS_ROOT=/cygdrive/n/cmiss (or whatever you have set CMISS_ROOT to).

  • Step 5: change into the cmiss root directory and use Subversion to checkout the cmgui module

    Assuming you have Subversion and your CMISS enironment variables set up correctly just type:

       cd $CMISS_ROOT
       svn checkout https://svn.physiomeproject.org/svn/cmiss/cmgui/trunk cmgui
    

  • Step 6: copy over the required image_libraries

    I used scp to copy over the required lib and include files for i386-win32 machines from bioeng22. If you want to have a look around the file structure on bioeng22, ssh there using:

       ssh yourusername@bioeng22.bioeng.auckland.ac.nz
    

    To secure copy the required image_libraries directories do the following:

       cd $CMISS_ROOT
       mkdir image_libraries
       mkdir image_libraries/lib
       mkdir image_libraries/include
       scp -r yourusername@bioeng22.bioeng.auckland.ac.nz:/hpc/cmiss/image_libraries/lib/i386-win32/ image_libraries/lib
       scp -r yourusername@bioeng22.bioeng.auckland.ac.nz:/hpc/cmiss/image_libraries/include/i386-win32/ image_libraries/include
    

  • Step 7: check out or copy over the required perl_interpreter code

    I used scp to copy over the required lib and source files for i386-win32 machines:

       cd $CMISS_ROOT
       mkdir perl_interpreter
       mkdir perl_interpreter/lib
       scp -r yourusername@bioeng22.bioeng.auckland.ac.nz:/hpc/cmiss/perl_interpreter/lib/i386-win32/ perl_intrpreter/lib
       scp -r yourusername@bioeng22.bioeng.auckland.ac.nz:/hpc/cmiss/perl_interpreter/source/  perl_interpreter 
    

  • Step 8: copy over the ITK source

    The ITK source is huge and takes a while to copy over:

       cd $CMISS_ROOT
       mkdir itk
       mkdir itk/lib
       scp -r yourusername@bioeng22.bioeng.auckland.ac.nz:/hpc/cmiss/itk/lib/i386-win32 i386-win32/ itk/lib
       scp -r yourusername@bioeng22.bioeng.auckland.ac.nz:/hpc/cmiss/itk/src/ itk
    

    Alternatively to build ITK from source you need to compile it using the MinGW windows environment or you have to patch the cygwin build so that it builds a MinGW version in cgywin.

    For MinGW (The disadvantage of this method is that it is likely to confuse a debugger if you need to debug cmgui and ITK and that was compiled with MinGW in cygwin, plus you need a different set of tools):

       download and install MinGW.  I used the windows installer, used the default installation path and selected the C++ compiler and the MinGW make.
       Download and install the Windows GUI version of cmake.
       Run cmake and point it to your itk source.
       Specify your build directory, a new directory you select.
       Push the configure.
       Select MinGW and if you used the default path for that, it should detect it and configure.
       Some of the tests seem to crash and show a windows prompt on my Vista box, just tell them to close.
       Specify your install path, probably $CMISS_ROOT/itk/i386-win32 as this is what cmgui will expect by default.
       Note you will save most of the disk space required if you don't build the examples and tests (my builds are 3.3GB with and 0.12GB without)
       Push the generate button.
       Open a windows command prompt, navigate to your build directory
       Ensure the c:\MinGW\bin directory is in your path
       Run 'mingw32-make'
       Run 'mingw32-make install'
    

    For cygwin mingw ITK-3.14.0-cygwin-mingw.patch:

       I applied some patches to Imagemagick to make the kwsys project realise it is win32 not unix,
       to fix a return code, and to fix some cast errors.  If I understood cmake I'm sure I could do better.
       The patch file is below, use the "patch -P0 < ITK-3.14.0-cygwin-mingw.patch" command to apply it to your source 
       Make a new empty build directory in a cygwin shell.
       In that directory run cygwin's cmake, replacing the path at the end of this command..
       ccmake -DCMAKE_CXX_FLAGS=-mno-cygwin -DCMAKE_C_FLAGS=-mno-cygwin PATH_TO_YOUR_ITK_SOURCE
       Push c to configure.
       Change the install path to somewhere you want, say $CMISS_ROOT/itk/i386-win32
       Maybe you want to save the disk required to build the examples and tests.
       Push c to configure again.
       Push g to generate.
       make
       When it fails (itktif and itksysEncodeExecutable) then restart the process with
       make VERBOSE=1
       so it shows you the failing command, and then repeat with the cygwin path replaced with a windows like path.
       Then keep going with
       make
       Finally
       make install
    

  • Step 9: change into the cmgui directory and run make

    Compiling should now be fairly simple:: cd $CMISS_ROOT/cmgui make

    All going well, this should compile an executable and copy it to the appropriate directory. Check it has been built by looking in the following directory:

       ls $CMISS_ROOT/cmgui/bin/i386-win32
    

    Note this executable will not be able to open up graphics consoles but it can still be used to run comfiles. You may like to create an alias to it so that you can run it from anywhere without typing the full path name. I put the following in my .bash_profile file:

       alias cmgui=$CMISS_ROOT/cmgui/bin/i386-win32/cmgui-debug.exe
    

Contributing to this site

Please add to the wiki any relevant information that you think might be useful to other users of this website. For example, you might like to contribute your experiences, questions and answers.

You are encouraged to contribute to this site regardless of your level of experience. Contributions are welcomed from new and regular visitors.

If you ask a question and receive an answer from a developer you should record it in the wiki. This information is extremely useful and can help other users overcome the same problem.

See how to add and edit pages for more information.