Building Demeter and Ifeffit on Windows with MinGW and Strawberry Perl

This is my page of notes on how I built IFEFFIT and DEMETER to work with Strawberry Perl and how I managed to build the DEMETER with Strawberry Perl installer package. These are mostly notes to myself, so this may not be completely coherent – raise an issue is anything is unclear.

First steps

  1. Install the latest version of Strawberry Perl from http://strawberryperl.com/. The rest of this page presumes that you have installed perl into C:\Strawberry.

    At the time of the most recent update of this document, the current version of Strawberry perl is 5.24.0.1.

  2. You may want to install the GutHub Desktop application from https://desktop.github.com/

  3. Clone a copy of DEMETER from https://github.com/bruceravel/demeter

  4. cd into the installation folder for DEMETER and do perl Build.pl. If you just installed (or updated) Strawberry Perl on your computer, you will be missing the mountain of dependencies that DEMETER uses, so ...

  5. At the command line, do perl Build installdeps and wait. This will take quite a while – even hours on a slow computer. Happily, once all the dependencies are installed, they are installed. When you upgrade DEMETER, this step will only be required to update any new dependencies.

The first time through, it took over 2 hours to compile up all the dependencies on my fairly old Windows machine. Three packages failed to install: Wx, Win32::Unicode::File, and File::Monitor::Lite.

Wx

This failed because one of the tests hung for some reason. Clicking the red X button allowed the tests to continue, but caused one to fail. It was safe to do cpanm -f -n Wx to force the installation despite the test failure. Of course, I had to pay attention and dismiss the window from the hung test....

Win32::Unicode::File

This failed a test having to do with printing a Unicode character to standard output. I suspect this has something to do with the terminal I was using on my Windows machine. In any case, it is benign in the context of how this module is used in Demeter. Doing cpanm -f -n Win32::Unicode::File is safe.

File::Monitor::Lite

Here, the failures have to do with a test failing to deal correctly with slashes and backslashes. Again doing cpanm -f -n File::Monitor::Lite is safe.

Any other problems – just do cpan -f <module> and see what happens. The worst case scenario is that you have to submit a bug report, thus making DEMETER better. Horrors!

Using Gnuplot

Grab the latest version of gnuplot from http://gnuplot.info/. You will be directed to SourceForge. Use the latest installer and have the installer put all the files in C:Strawberrycbingnuplot. When prompted for the default terminal type, you can select any, but my preferred choice is wxt.

Preparing to compile Ifeffit

Here is a useful page on using pgplot and MinGW.

First, need to establish a build environment from which Strawberry+Demeter can be bootstrapped.

  1. Would like to have installed PDCurses and Readline from GnuWin32 into C:\GnuWin32 (or somewhere), but I could not get these to work with my 64-bit build. See below.
  2. It is no longer necessary to fetch a copy of gfortran from MinGW. Strawberry now comes with it.
  3. Installed the pre-built pgplot and GrWin libraries available at http://spdg1.sci.shizuoka.ac.jp/grwinlib/english/ into C:\MinGW\lib\pgplot (or grab them from an old Demeter installer).
  4. Set the PGPLOT_DIR variable to /c/mingw/lib/pgplot, which is the location to which pgplot was installed in step 3.
  5. In principle, PGPLOT_DEV should be set to /GW, but that does not seem to get picked up by IFEFFIT. I have to do $plot_device=/gw before plotting.

Compiling Ifeffit to be placed in C:/strawberry

  1. Replace iconf_pgplot, iconf_term, and iconf_iff with the versions from win/ in the DEMETER distribution

  2. Modify line 85 of the main Makefile.in to read

    SUBDIRS = src
    

    (i.e. remove readline so it does not get compiled.)

  3. Modify line 90 in src/cmdline/Makefile.in to read

    readline_LIB = $(TERMCAP_LIB)
    
  4. Do

    ./configure --prefix='/c/strawberry/c/lib'
    

    (Note: this should be done in the MinGW window and not in the Windows command prompt.)

  5. Edit src/lib/sys.h, changing the sysdir and pgdev lines like so:

    c{sys.h  -*-fortran-*-
    c system and build specific stuff goes here
    c to be included in iff_config.f
           sysdir = 'C:\strawberry\c\share\ifeffit'
           pgdev  = '/gw'
           inifile= 'startup.iff  .ifeffit'
           build = '1.2.11d'//
          $   ' Copyright (c) 2008 Matt Newville, Univ of Chicago'
    c}
    
  6. Now make and make install .

    You may instead need to do make -k and make -k install if you run into trouble building the command line ifeffit.

curses and readline

The readline library compiled for 64 bit Windows and usable with the mingw toolchain is available here. Open the 7zip file and copy the various files in the bin, include, lib, and share folders into C:\Strawberry\c (or wherever your DEMETER root is located).

I could not find a pre-compiled curses library, nor could I figure out how to compile PDCurses on my Windows/mingw machine. As a result, I was unable to compile the command line version of ifeffit, although the library compiled up just fine. Thus the installer package does not currently have a copy of the command line ifeffit.

Without a curses library, you will certainly need to do make -k and make -k install to skip over the problem building the command line ifeffit.

Compiling the SWIG wrapper

I found that the wrapper generated by SWIG 1.3.1 works well but that the wrappers from 1.3.4 or 2.0.2 do not. I have not investigated the cause yet and have the 1.3.1 wrapper committed to the git repository.

Here is the file defining the compilation and linking rules for the IFEFFIT SWIG wrapper.

  • the linking order is important.
  • the locations of MinGW, GnuWin, and strawberry are currently hardwired

In any case, it should compile up just fine when you do the perl Build step. If you have build DEMETER for an earlier version of perl, you should do perl Build touch_wrapper to make sure the SWIG wrapper is rebuilt.

If rebuilding after updating Strawberry, don't forget to do perl ./Build touch_wrapper, which forces a rebuild of the wrapper.

Note

The block around lines 36-42 in DemeterBuilder.pm attempts to set the root of the DEMETER installation correctly. (It is C:\Strawberry\c on my build machine.) Make sure it resolves to the correct location on your machine.

Building documentation

The documentation requires Sphinx, which I did not bother to install on my computer. I just built the document on a linux machine and zipped it up in a directory structure that looks like this:

where each of Artemis, Athena, DPG, and SinglePage contains the contents of their respective _build/html folders.

This tree is then dropped in place in C:\Strawberry\perl\site\lib\Demeter\share.

With Sphinx, I imagine it would build and install normally. Building with also requires these packages: pybtex, sphinxcontrib-bibtex, and sphinxcontrib-blockdiag, which can be installed with pip.




DEMETER is copyright © 2009-2016 Bruce Ravel – This document is copyright © 2016 Bruce Ravel

This document is licensed under The Creative Commons Attribution-ShareAlike License.

If DEMETER and this document are useful to you, please consider supporting The Creative Commons.