file_logo

AMIDE: Amide's a Medical Imaging Data Examiner

.


Notes on compiling AMIDE 0.8.x and associated programs on Microsoft Windows

Note - these are older notes, used for compiling version 0.8.22 and prior. Newer notes are here.

This is a long, involved process, and assumes a good command of standard GNU build environments. Be aware that these notes are fragmentary and may contain bugs and omissions.

The first step of the process involves setting up a build system to compile AMIDE for windows. There are three basic options. 1) Setup a cross-compilation setup under Linux - I've never tried this approach. 2) Use MinGW/MSYS on Windows - I've tried this approach, but have found it overly complex due to these packages being poorly maintained. 3) Use Cygwin with the MinGW libraries - this is the process I've been using. As I've essentially only been using the Cygwin + MinGW build system, the following text will be only directly relevant to this build system. Cygwin+MinGW means setting up cygwin such that compilation of applications inside of cygwin only depend on microsoft DLL's and don't depend on cygwin.dll.

Helpful Hints:

  • The following will show what DLL's a library or executeable you built depends on. If one of the DLL's is cygwin.dll, you didn't setup your build environment correctly.
    	objdump -p filename.dll | grep DLL
    
  • To see what include files the compiler is dragging in, add -H to the gcc line in the Makefile
  • When stuck, suspect incorrect permissions on your DLL's. Sometimes third party DLL's get installed without correct permisions, do a "chmod a+x *.DLL" to fix that. Pop-up errors with 0x00022 (or something like that) as the error message are usually because of this.


Instructions

  1. From the AMIDE project page, download the AMIDE Windows Sources to get various needed patches, files, and my version of libgnomeui.

  2. Install cygwin. In addition to the default packages, you'll definitely need:
         autoconf
         automake
         gcc
         gcc-mingw
         gcc-c++
         libtool
         make
         patch
         expat
         mingw-zlib
    
    You'll probably also want:
         cygutils
         diff
         emacs
         man
         more
         openssh
         unzip
         zip
    

    And you'll need to add the following to .bash_profile
    	export CC='gcc -mcpu=pentium -march=i386 -mno-cygwin -mms-bitfields'
    	export CXX='g++ -mcpu=pentium -march=i386 -mno-cygwin -mms-bitfields'
    	export CPPFLAGS='-I/usr/local/include'
    	export LDFLAGS='-L/usr/local/lib'
    

  3. Install stuff from Cygwin Ports. You'll need:
           perl-XML-Parser (2.3.4 as of this writting)
    

  4. Get GTK+ for Windows from Dropline's web site. You will need both the runtime and development packages. Install the runtime package in its default location. Install the development package in C:\cygwin\usr\local

    Add the following lines to .bash_profile to enable access to the GTK dll's. If you installed the GTK runtime kit somewhere else, modify the lines appropriately. Also, make sure that the cygwin pkg-config (/bin/pkg-config) comes after the one supplied in the dropline development kit (/usr/local/bin/pk-config).

     
          export PATH=/usr/local/bin:/usr/local/lib:${PATH}
          export PATH=/cygdrive/c/Program\Files/Common\ Files/GTK/2.0/lib:${PATH} 
    
    Edit /usr/local/lib/pkgconfig/pangowin32.pc, and change "-lgdi" to "C:/WINDOWS/system32/gdi32.dll".

    --> --> Copy "intltool.m4" from my amide_windows_sources to /usr/local/share/aclocal

    Copy "libxml-2.0.pc" from my amide_windows_sources to /usr/local/lib/pkgconfig

    Get gtk-doc.m4 from a full gtk installation (like on your Linux box) and copy it into /usr/local/share/aclocal

    Delete /usr/local/lib/libxml2.la


  5. We'll need to generate dll import libraries for libintl and libiconv. Download pexports, unzip the package, chmod a+x the binary (pexports) and move it to someplace in your path. Then run:
         pexports.exe C:/PROGRA~1/COMMON~1/GTK/2.0/lib/iconv.dll | sed 's/^_//' > iconv.def
         pexports.exe C:/PROGRA~1/COMMON~1/GTK/2.0/lib/intl.dll | sed 's/^_//' > intl.def
         dlltool.exe --dllname iconv.dll --intput-def iconv.def --output-lib libiconv.dll.a
         dlltool.exe --dllname intl.dll --input-def intl.def --output-lib libintl.dll.a
         ranlib libiconv.dll.a
         ranlib libintl.dll.a
         mv libiconv.dll.a /usr/local/lib
         mv libintl.dll.a /usr/local/lib
    

  6. Download popt (1.7 known to work), unpack, get my patch from amide_windows_sources, and run the following:
         patch -p1 < popt-1.7-DLL.patch
         libtoolize -f
         aclocal -I macros
         automake -f -a -c
         autoconf -f
         ./configure --disable-nls --target=i386-pc-mingw32 --build=i386-pc-mingw32
         [edit Makefile, add a '-lintl' to the LDFLAGS line]
         make
         make install 
    

  7. Download libart_lgpl (2.3.14 is known to work), unpack, and run the following:
          libtoolize -f
          aclocal
          automake -f -a -c
          autoconf -f
          ./configure --target=i386-pc-mingw32 --build=i386-pc-mingw32
          make 
          make install
    

  8. Download libgnomecanvas (2.4.0 as of this writing), unpack, and run the following.
          libtoolize -f
          aclocal -I /usr/local/share/aclocal
          automake -f -a -c
          autoconf -f
          CFLAGS=-I/usr/local/include/freetype2 ./configure \\
                --target=i386-pc-mingw32  --build=i386-pc-mingw32
          make 
          make install
    

  9. From the AMIDE windows sources, get my heavily modified libgnomeui. This version doesn't depend on gconf, libbonoboui, libgnome, or libglade. To enable that, I stripped out a lot of functionality, and what's left is what AMIDE actually needs.
          libtoolize -f 
          aclocal -I /usr/local/share/aclocal 
          automake -f -a -c
          autoconf -f
          ./configure --target=i386-pc-mingw32 --build=i386-pc-mingw32
          make
          make install
    

  10. Get nifticlib so that xmedcon will include NIFTI support. I'm using version 0.5.
        cmake -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF \\
              -DNIFTI_INSTALL_INCLUDE_DIR=/usr/local/include \\
    	  -DZLIB_LIBRARY=/usr/lib/mingw/libz.a -DCMAKE_COMPILER_IS_MINGW=1 \\
    	  -DCMAKE_VERBOSE_MAKEFILE=OFF .
    
    • edit znzlib/CMakeFiles/znz.dir/link.txt and change cygznz to libznz
    • edit niftilib/CMakeFiles/niftiio.dir/link.txt and change cygniftiio to libniftiio
    • edit niftilib/CMakeFiles/niftiio.dir/build.txt and change cygznz to libznz
    • edit nifticdf/CMakeFiles/niftcdf.dir/link.txt and change cygnifticdf to libnifticdf
    • edit the util/CMakeFiles/*/build.txt and Testing/libnifti/CMakeFiles/*/build.txt files by changing cyg* to lib*
        make
        cp */*.dll /usr/local/bin
        cp */*.dll.a /usr/local/lib
        mkdir /usr/local/include/nifti
        cp */*.h /usr/local/include/nifti
    
  11. Get xmedcon. You'll need version >= 0.9.7.2
          [You'll need to comment out the AM_PATH_GLIB, AM_PATH_GTK, 
                  and AM_PATH_GDK_PIXBUF lines in configure.in, 
                  along with the surrounding if/fi]
          libtoolize -f 
          aclocal
          automake -f -a -c
          autoconf -f
          ./configure --target=i386-pc-mingw32 --build=i386-pc-mingw32 \\
                      --enable-glib=no --enable-gui=no --prefix=/usr/local \\
    		  --enable-nifti --with-nifti-prefix=/usr/local
          make
    
    Now, edit xmedcon-config and delete the "@GLIB_CFLAGS@" and "@GLIB_LIBS@".

    And finish with:

          make install
    

  12. From the AMIDE download page, get volpack.
          libtoolize -f 
          aclocal 
          automake -f -a -c
          autoconf -f
          ./configure --target=i386-pc-mingw32 --build=i386-pc-mingw32
          make
          make install
    

  13. Get libfame along with my patch from amide_windows_sources. Note, the supplied windows libraries will not work! You'll need at least version 0.9.1. To recompile:
          patch -p1 < libfame-0.9.1-DLL.patch
          [Make sure ltconfig, acinclude.m4 get removed]
          touch acinclude.m4
          libtoolize -f 
          aclocal
          automake -f -a -c
          autoconf -f
          ./configure --enable-mmx=no --target=i386-pc-mingw32 \\
                      --build=i386-pc-mingw32
          make
          make install
    

  14. Get the DCMTK library. You'll want the "Unix" package (.tar.gz). Version 3.5.4 is known to work. By default, only the static libraries are built, which is fine for us. To compile:
         ./configure --disable-threads --target=i386-pc-mingw32 \\
                     --build-i386-pc-mingw32
         make
         cd dcmdata/libsrc
         [edit mkdictbi.cc - change "LPTSTR" to "WCHAR *" on line 161]
         [edit Maefile - add -lnetapi32 to LOCAL_LIBS]
         make mkdictbi
         ./mkdictbi.exe ./dicom.dic ./private.dic > dcdictbi.cc
         make
         cd ../..
         make install
         make install-lib
    

  15. Get GSL (gsl 1.4 works), along with my patch.
         patch -p1 < gsl-1.4-DLL.patch
         libtoolize -f
    
    If needed (libtool 1.5?) edit the generated libtool and ltmain.sh so that the S_IXOTH and S_IXGRP containg lines look like this:
           (
    #if defined (S_IXOTH)
            ((st.st_mode & S_IXOTH) == S_IXOTH) ||
    #endif
    #if defined (S_IXGRP)
            ((st.st_mode & S_IXGRP) == S_IXGRP) ||
    #endif
           ......
    
    Then continue with
         aclocal -I /usr/local/share/aclocal 
         automake -f -a -c
         autoconf -f
         ./configure --target=i386-pc-mingw32 --build=i386-pc-mingw32
         make [ will fail with missing gslcblas warning]
         cd cblas
         make install
         cd ..
         make
         make install
    

  16. Finally, get AMIDE.
         libtoolize -f
         aclocal -I /usr/local/share/aclocal -I macros
         automake -f -a -c [ignore the unused variable AMIDE_WIN32_LDFLAGS error]
         autoconf -f
          ./configure --target=i386-pc-mingw32 --build=i386-pc-mingw32 \\
                     --enable-mswin-hacks --enable-amide-debug=no 
         make
         [if needed, add -lwsock32 to AMIDE_LIBDCMDATA_LIBS in src/Makefile]            
         make install    
    
    Note, sometimes I build this, I can't get the AM_PATH_LIBFAME macro to work in configure.in. In that case, change it to AC_CHECK_LIB.

  17. Now for generating amide_setup.exe. In the amide's sources win32 directory, there's a file amide-VERSION.iss. This file is used by Inno Setup, a neat little program for generating windows application install programs. We first need to setup the directory for Inno Setup to use. We need to create an amide folder, several subdirectories inside of it, and copy several files into the folders. Do the following (where Desktop is the path to your Desktop directory):
         mkdir Desktop/amide-VERSION/bin
         mkdir Desktop/amide-VERSION/lib
         mkdir Desktop/amide-VERSION/share
    
    
    
         mkdir Desktop/amide-VERSION/share/pixmaps
    
         cd /usr/local/bin
         cp amide.exe Desktop/amide-VERSION
         cp libart_lgpl_2-2.dll 
            libfame-0-9-0.dll 
    	libgnomecanvas-2-0.dll 
    	libgnomeui-2.0.dll
    	libgsl-0.dll
    	libgslcblas-0.dll
    	libmdc-2.dll
    	libniftiio-0.0.0.dll
    	libpopt-0.dll
    	libvolpack-1.dll
    	libznz-0.0.0.dll
    	mgwz.dll
    	Desktop/amide-VERSION/bin
         cp /usr/lib/mingw/zlib1.dll Desktop/amide-VERSION/bin/mgwz.dll
    
         cp -a /usr/local/lib/locale Desktop/amide-VERSION/lib
    
    
         cp [AMIDE SOURCE directory]/COPYING Desktop/amide-VERSION
         cp [AMIDE SOURCE directory]/pixmaps/amide_logo.png \\ 
            Desktop/amide-VERSION/share/pixmaps
    
    Do to a problem with the version 2.2.4-2 of the GTK+ For Windows package, also need to do the following. Note the slightly changed library names.
    
    
         cp C:/Program\ Files/Common\ Files/GTK/2.0/lib/freetype6.dll \\
            Desktop/amide-VERSION/bin/freetype-6.dll
    
    
    And on a box with xsltproc installed (like a linux box), run the following:
    
    xsltproc -o help/C /usr/share/sgml/docbook/xsl-stylesheets/xhtml/chunk.xsl \\
             /usr/share/gnome/help/amide/C/amide.xml
    xsltproc -o help/es /usr/share/sgml/docbook/xsl-stylesheets/xhtml/chunk.xsl \\
             /usr/share/gnome/help/amide/es/amide.xml
    
    And copy the resulting directory into Desktop/amide-VERSION

  18. Now just compile using Inno Setup, and that should be it.....




last modified AML 2007-12-02 Validate: CSS & HTML Project hosted by: SourceForge.net Logo