Ifeffit and Friends 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. It may not be completely coherent -- if you want to replicate what I have done, let me know and I'll clean this page right up.

Compiling 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. Removed readline from line 85 of the main Makefile:

    SUBDIRS = readline src 
  2. Installed PDCurses and Readline from GnuWin32 into C:\GnuWin32\

  3. Installed a full MinGW package because Strawberry does not come with the Fortran compiler. I put this into in C:\MinGW\.

  4. Installed the pre-built pgplot and GrWin libraries available at http://spdg1.sci.shizuoka.ac.jp/grwinlib/english/ into C:\MinGW\lib\pgplot\

  5. Correct value of PGPLOT_LIBS:

    PGPLOT_LIBS = -L/c/MinGW/lib/pgplot -lcpgplot -lpgplot -lGrWin -lgdi32 -lg2c

    Need to hack at iconf_pgplot to make this happen.

  6. In src/cmdline/Makefile I used this for readline_LIB

    readline_LIB = -L/c/GnuWin32/lib -lcurses -lreadline
  7. Set the PGPLOT_DIR variable to /c/mingw/lib/pgplot, which is the location to which pgplot was installed in step 4.

  8. In principle, PGPLOT_DEV should be set to /GW, but that does not seem to get picked up by Ifeffit. I have to $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. ./configure --prefix='/c/source/Demeter.prereqs' (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}

    Note that this somewhat changes how the Ifeffit build procedure works. By setting the prefix at configuration time to be different from the sysdir, Ifeffit will get installed into a staging area. It will then be installed into its proper home when the Strawberry package is built.

  6. Now make and make install

What goes into Demeter.prereqs

Once everything is in place, zip up Demeter.prereqs in a zip file called Demeter.prereqs.zip and move that zip file to C:\git\demeter\win\.

Note that the Ifeffit wraper must be built against a properly built version of Ifeffit. This probably means ether building Demeter from source as part of the Strawberry build or:

  1. Build Ifeffit
  2. Build Strawberry
  3. Build Demeter using the Strawberry that just got built
  4. Build a Demeter par file
  5. Rebuild Strawberry

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 repo.

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

Using Gnuplot

Grab the latest version of gnuplot from http://sourceforge.net/projects/gnuplot/files/gnuplot/. There are zip files with Windows builds to be found there. In recent versions, there is a gnuplot.exe version that emulates pipes without opening a command window. Point the gnuplot -> program configuration variable at that and you should be able to use the gnuplot plotting backend. (Set plot -> plotwith to gnuplot.)

Using gnuplot on windows with Demeter requires a modified version of Graphics::GnuplotIF. I have passed a patch upstream to the author. Hopefully it will become available on CPAN.


Strawberry Perl + Demeter

The relocation of Perl does not seem to happen correctly when installing not in C:\strawberry. See http://www.perlmonks.org/?node_id=883855

Do this:

  1. Install Strawberry from the msi package. Click through the error that happens when relocation fails.
  2. Remove the line

    perl\lib\auto\Locale-Maketext\.packlist:backslash

    from c:/source/strawberry/strawberry-merge-module.reloc.txt. This seems to be the reason that relocating fails during installation.

  3. Run the relocation script in C:\source\strawberry by hand

  4. Proceed with the instructions at http://strawberryperl.com/documentation/building.html although you will need to grap the latest Alien::WiX from Curtis Jewell's mercurial repository at http://hg.curtisjewell.name/Alien-WiX/ and install that instead. Also install WiX from that same repository.

To get things working with Perl 5.12.2 (the current version of Strawberry at this time), grab and install these:

PDWix uses LWP::UserAgent. So you have to put the http_proxy in the environment. In the MinGW shell, doing

export http_proxy=http://192.168.1.130:3128

before building did the trick.

Errors in simple script to build dependency tree:


Modifying the BAT files

At line 7 of each .batfile generated by Module::Build to run the perl scripts, you will find this invocation of perl:

perl -x -S %0 %*

This will call perl and feed it the perl code that follows the BAT code at the top of the file.

Each .bat file should be modified to capture STDOUT and STDERR to a file for the sake of bug reporting. This can be done like so:

perl -x -S %0 %*  > "%APPDATA%\demeter\dathena.log" 2>&1

Each of Athena, Artemis, Hephaestus, and Atoms should get its own log file.

See this explanation of DOS batchfile redirection.


Demeter/IfeffitMingw (last edited 2011-06-21 20:43:10 by BruceRavel)