Thanks for that, I've now got a project that builds (and even runs!) For the benefit of anyone else who has similar problems, some things that I have learnt are:
0: If you are trying to build your code and statically link it to a pre-built library(ies), you need exactly the same version of compiler (and probably the rest of the toolchain) that was used to build the libraries.
1: There are a number of projects called 'MinGW' or variants of it. So if you're trying to match someone else's MinGW toolchain, you first need to know which MinGW project they used, and then the version.
2: MinGW has many components, each with it's own version number. The version number that gets quoted is the version of gcc (I think...)
3: The official binaries and dependencies (linked here: https://www.allegro.cc/forums/thread/616006/0) use 'MinGW-w64' (https://sourceforge.net/projects/mingw-w64/) version 5.3.0. The sourceforge page lets you download an installer, which in turn will let you choose a version.
4: When you have installed MinGW, you should add <your mingw directory>\bin to your windows path. If you have more than one MinGW installation (because you've been trying to figure out which is the right version you should probably only have one path entry, or risk extreme confusion
5: Code::Blocks auto-detect (under Settings|Compiler|toolchain executables) doesn't work very well, especially if you have multiple versions of MinGW. So browse to the directory, and then to the program files (gcc, g++, g++, ar GDB/CDB debugger, windres.exe, mingw32-make worked for me...)
6: The libs should be added as per the tutorial here:
but you will also need libpng16.a and libjpeg.a (from the dependencies) and libshlwapi.a (from the MinGW libs). libpng16.a MUST appear ABOVE libzlib.a in the list. I had libshlwapi at the bottom of the list.
7: The tutorial says that you should add:
to 'Other linker settings'. In addition, you will also need to add
8: Don't forget to #define ALLEGRO_STATICLINK
I think that's all. Some of this was determined by trial-and-error and guesswork, so if anyone who knows better can correct me, please go ahead. I may try to update the wiki tutorial with some of this in due course.