file_logo

AMIDE: Amide's a Medical Imaging Data Examiner

.


Notes on compiling AMIDE and associated programs on Microsoft Windows

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. 2) Use MinGW/MSYS on Windows - I've tried this approach, but have found it overly complex due to these packages being poorly maintained and differences between unix and dos file paths. 3) Use Cygwin with the MinGW libraries. For a long time I was using option #3. As of AMIDE version 1.0.3, I've been using option #1.

Helpful Hints:

  • The following will show what DLL's a library or executeable you built depends on. This is useful for making sure an inappropriate DLL didn't get dragged in.

        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. 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. SETUP FEDORA: I use fedora linux, which has prebundled mingw crossbuild packages. You'll want to install the following packages with yum. I'm setting up to build both 32bit and 64bit binaries:

        mingw32-gtk2
        mingw64-gtk2
        mingw32-libxml2
        mingw64-libxml2
        wine [wine.x86_64 has both i686 and x86_64 binaries]
        glibc-devel.i686 [if not already installed]
      

    You'll also need to change the permissions on the mingw crossbuild directory so you can install the built applications there. As root (or using sudo).

        chown -R YOUR_USERNAME /usr/i686-w64-mingw32/sys-root
        chown -R YOUR_USERNAME /usr/x86_64-w64-mingw32/sys-root
      
  2. LIBART_LGPL: You'll need to compile your own libart, as it's no longer packaged for the mingw crossbuild environment on fedora. Download libart_lgpl (2.3.21 as of this writing), and run the following.

        mingw32-configure
        mingw32-make
        mingw32-make install
      

    And in a separate directory

        mingw64-configure
        mingw64-make
        mingw64-make install
      
  3. LIBGNOMECANVAS: You'll need to compile your own libgnomecanvas, as it's no longer packaged for the mingw crossbuild environment on fedora. Download libgnomecanvas (2.30.3 as of this writing), and run the following.

    Get this patch: libgnomecanvas_ft2_dep_removed.patch. This removes explicity dependends on freetype for antialiased mode fonts in libgnomecanvas, allowing other rendering backends to be used.

        mingw32-configure
        patch -p1 < libgnomecanvas_ft2_dep_removed.patch
        mingw32-make
        mingw32-make install
      

    And in a separate directory

        mingw64-configure
        patch -p1 < libgnomecanvas_ft2_dep_removed.patch
        mingw64-make
        mingw64-make install
      
  4. GTK THEME: This is actually optional, but is needed if you want the final application to look good. The default theme for GTK on win32 is really uglly... Download gtk--engine (2.20.2 as of this writing, don't use numbers greater then 2.90 as they're for gtk3), and run the following.

        mingw32-configure
        mingw32-make
        mingw32-make install
      

    And in a separate directory, need to update libtool for the 64bit build.

        [edit Makefile.am, remove "test" from the first line]
        aclocal
        autoconf -f
        automake -f -a -c
        libtoolize -f -c
        mingw64-configure
        mingw64-make
        mingw64-make install
      
  5. VOLPACK: From the AMIDE download page, download volpack.

        mingw32-configure
        mingw32-make [will error out]
        gcc -o src/makeopts src/makeopts.c
        mingw32-make
        mingw32-make install
      

    And in a separate directory

        mingw64-configure
        mingw64-make [will error out]
        gcc -o src/makeopts src/makeopts.c
        mingw64-make
        mingw64-make install
      
  6. XMEDCON: Download xmedcon. You'll want version >= 0.11.1.
        mingw32-configure
        gcc -o libs/dicom/parse libs/dicom/parse.c
      

    Edit source/Makefile: change "windres" to "i686-w64-mingw32-windres"

    Edit source/appicon.rc, and change to unix style directory delimitors

        mingw32-make
        mingw32-make install
      

    And in a separate directory

        mingw64-configure
        gcc -o libs/dicom/parse libs/dicom/parse.c
      

    Edit source/Makefile: change "windres" to "x86_64-w64-mingw32-windres"

    Edit source/appicon.rc, and change to unix style directory delimitors

        mingw64-make
        mingw64-make install
      
  7. DCMTK: Download the DCMTK library. You'll want the "Unix" package (.tar.gz). I'm currently using a beta version (dcmtk-3.6.1_20120831).
        mingw32-cmake -i [Just hit enter through all the options]
      

    edit ofstd/include/dcmtk/ofstd/offile.h, and change __MINGW64__ to __MINGW32__ in two locations.

        mingw32-make
        mingw32-make install
      

    And in a separate directory

        mingw64-cmake -i [Just hit enter through all the options]
    
        mingw64-make
        mingw64-make install
    
      
  8. FFMPEG: Download ffmpeg. Currently using version 2.1.3.
        ./configure --prefix=/usr/i686-w64-mingw32/sys-root/mingw --cross-prefix=i686-w64-mingw32- \
                    --arch=x86 --target-os=mingw32 --enable-gpl --enable-memalign-hack \
                    --enable-shared --disable-asm
        mingw32-make
        mingw32-make install
      

    And in a separate directory

        ./configure --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw --cross-prefix=x86_64-w64-mingw32- \
                    --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-memalign-hack \
                    --enable-shared --disable-asm
        mingw64-make
        mingw64-make install
      
  9. AMIDE: Finally, download AMIDE.

    Start by manually building the .ico files

        cd win32
        for i in *.png; do pngtopam $i > ${i%png}tmp; done
        for i in *.png; do pngtopam -alpha $i > ${i%png}pnma; done
        for i in *.tmp; do ppmquant 256 $i > ${i%tmp}pnm; done
        ppmtowinicon -andpgms amide_logo*.pnm* -output amide.ico
        ppmtowinicon -andpgms  amide_file_logo*.pnm* -output amide_file.ico
        cd ..
      

    And then continue with

        mingw32-configure --enable-amide-debug=no --enable-gtk-doc=no --disable-doc
      

    Edit win32/Makefile, change "windres" to "i686-w64-mingw32-windres"

        mingw32-make
        mingw32-make install
      

    Now for the x86_64 build. In a separate directory - repeat the above for generating the .ico file.

        mingw64-configure --enable-amide-debug=no --enable-gtk-doc=no --disable-doc
      

    Edit win32/Makefile, change "windres" to "x86_64-w64-mingw32-windres"

        mingw64-make
        mingw64-make install
      
  10. PACKAGING: Now for generating amide_setup.exe. The instructions below are for the 32bit version, creating the 64bit version should be identical except for the different mingw directory.

    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.

    Under Linux, we'll setup the directory for Inno Setup to package. We need to create an amide folder, several subdirectories inside of it, and copy several files into the folders. Do the following (adjust as needed for where your build directory is):

        export VERSION=1.0.4 [Or whatever the current version is]
        export SOURCE_ROOT=[where ever your amide source directory is]
      

    And for i686 bundling

        export BUILD_ROOT=/home/scratch/mingw32/build/amide-$VERSION
        export INSTALL_ROOT=/usr/i686-w64-mingw32/sys-root/mingw
      

    Or if generating the x86_64 bundle

        export BUILD_ROOT=/home/scratch/mingw64/build/amide-$VERSION
        export INSTALL_ROOT=/usr/x86_64-w64-mingw32/sys-root/mingw
      

    Then start makng the build directory

        mkdir -p $BUILD_ROOT
        cd $BUILD_ROOT
        mkdir -p bin share/pixmaps etc \
                 lib/gdk-pixbuf-2.0/2.10.0/loaders \
                 lib/pango/1.6.0/modules 
      

    Copy the executables and dlls from the mingw32 install location to the build directory

        cd $INSTALL_ROOT/bin
    
        cp -t $BUILD_ROOT/bin \
        amide.exe \
        avcodec-54.dll \
        avutil-51.dll \
        iconv.dll \
        libart_lgpl_2-2.dll \
        libatk-1.0-0.dll \
        libcairo-2.dll \
        libdcmdata.dll \
        libexpat-1.dll \
        libffi-6.dll \
        libfontconfig-1.dll \
        libfreetype-6.dll \
        libgailutil-18.dll \
        libgdk-win32-2.0-0.dll \
        libgdk_pixbuf-2.0-0.dll \
        libgio-2.0-0.dll \
        libglib-2.0-0.dll \
        libgmodule-2.0-0.dll \
        libgnomecanvas-2-0.dll \
        libgobject-2.0-0.dll \
        libgsl-0.dll \
        libgslcblas-0.dll \
        libgtk-win32-2.0-0.dll \
        libintl-8.dll \
        libmdc-2.dll \
        liboflog.dll \
        libofstd.dll \
        libpango-1.0-0.dll \
        libpangocairo-1.0-0.dll \
        libpangoft2-1.0-0.dll \
        libpangowin32-1.0-0.dll \
        libpixman-1-0.dll \
        libpng15-15.dll \
        libvolpack-1.dll \
        libxml2-2.dll \
        libgcc_s_sjlj-1.dll \
        libstdc++-6.dll \
        zlib1.dll 
    
        cd $BUILD_ROOT
      

    Get the pango configuration information

        cp -a $INSTALL_ROOT/etc/pango etc
      

    Get the pango and pixbuf dll's

        mkdir -p lib/gdk-pixbuf-2.0/2.10.0/loaders
        mkdir -p lib/pango/1.6.0/modules
        cp $INSTALL_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.dll \
                        lib/gdk-pixbuf-2.0/2.10.0/loaders
        cp $INSTALL_ROOT/lib/pango/1.6.0/modules/*.dll \
                        lib/pango/1.6.0/modules
      

    [Optional] Include medcon/xmedcon:

        cp $INSTALL_ROOT/bin/medcon.exe bin
        cp $INSTALL_ROOT/bin/xmedcon.exe bin
      

    Copy the locale information

        cp -a $INSTALL_ROOT/share/locale share
      

    From the amide source directory, get the following files:

        cp $SOURCE_ROOT/COPYING ./
        cp $SOURCE_ROOT/pixmaps/amide_logo.png share/pixmaps
        cp $SOURCE_ROOT/pixmaps/amide_file_logo.png share/pixmaps
      

    And to create .html files for the windows help browser, you'll need to have the linux version of AMIDE installed on your system. Then run the following and copy the resulting help directory into BUILD/amide-VERSION/share/gnome/help/amide

        mkdir -p share/gnome/help/amide
        cd share/gnome/help/amide
        mkdir C es
    
        cd C
        xsltproc /usr/share/sgml/docbook/xsl-stylesheets/xhtml/chunk.xsl \
                 /usr/share/gnome/help/amide/C/amide.xml
        cp index.html amide.html
        cp -a /usr/share/gnome/help/amide/C/figures ./
        cd ../es
        xsltproc /usr/share/sgml/docbook/xsl-stylesheets/xhtml/chunk.xsl \
                 /usr/share/gnome/help/amide/es/amide.xml
        cp index.html amide.html
        cp -a /usr/share/gnome/help/amide/C/figures ./
        
        cd ../../../../..
      

    Now get a nice looking theme, I'm using Clearlooks at the moment:

        mkdir -p etc/gtk-2.0
        mkdir -p lib/gtk-2.0/2.10.0/engines
    
        cp $INSTALL_ROOT/share/themes/Clearlooks/gtk-2.0/gtkrc etc/gtk-2.0/
        cp $INSTALL_ROOT/lib/gtk-2.0/2.10.0/engines/libclearlooks.dll lib/gtk-2.0/2.10.0/engines
      

    Make sure everything is executable

        chmod a+x `find -name "*.exe"`
        chmod a+x `find -name "*.dll"`
      

    Decrease size of things to make smaller for packaging.

        strip `find -name "*.exe"`
        strip `find -name "*.dll"`
      

    Now copy the amide-VERSION.iss file that comes with amide (in the etc directory) into the directory containg the BUILD directory, and feed that into into Inno Setup.

        cp $SOURCE_ROOT/etc/amide-$VERSION-1.iss ../
      




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