Up until imlib2-1.4.5, imlib2-config --libs
published -lX11 and w3m used that to get the X11 library flags to finish linking. However, imlib2-config from imlib2-1.4.6 no longer publishes that flag:
$ imlib2-config --libs -L/usr/really-local/lib -lImlib2
This is the minimal patch against w3m-0.5.3 that lets w3mimgdisplay link. A more proper patch should actually check for the presence of the X11 library in configure and use $(X_LIBS) or some similar token in Makefile.
--- a/Makefile.in 2011-01-04 04:22:18.000000000 -0500 +++ b/Makefile.in 2014-01-31 10:22:25.000000000 -0500 @@ -199,7 +199,7 @@ $(CC) $(CFLAGS) -DDUMMY -c -o $@ $? $(IMGDISPLAY): w3mimgdisplay.o $(ALIB) w3mimg/w3mimg.a - $(IMGLINK) $(CFLAGS) -o $(IMGDISPLAY) w3mimgdisplay.o w3mimg/w3mimg.a $(LDFLAGS) $(LIBS) $(IMGLDFLAGS) + $(IMGLINK) $(CFLAGS) -o $(IMGDISPLAY) w3mimgdisplay.o w3mimg/w3mimg.a $(LDFLAGS) $(LIBS) $(IMGLDFLAGS) -L/usr/X11R6/lib -lX11 w3mimgdisplay.o: w3mimgdisplay.c w3mimg/w3mimg.h $(CC) $(CFLAGS) $(IMGCFLAGS) -o $@ -c $(srcdir)/w3mimgdisplay.c
In Debian w3m 0.5.3-14, fixed with another patch:
https://github.com/tats/w3m/commit/bc4000470194df630837b2b0acd1ea4e9d1702b5
See also Debian bug#734425:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734425