--- a/configure
+++ b/configure
@@ -16515,7 +16515,7 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_destroy_write_struct" >&5
 $as_echo "$ac_cv_lib_png_png_destroy_write_struct" >&6; }
 if test "x$ac_cv_lib_png_png_destroy_write_struct" = x""yes; then :
-  LIBS="$LIBS -lpng -lz"
+  LIBS="-lpng -lz $LIBS"
 else
   HAVE_PNG="no"
 fi
--- a/configure.in
+++ b/configure.in
@@ -244,7 +244,7 @@ dnl (PNG page export)
 dnl
 HAVE_PNG="yes"
 AC_CHECK_LIB(png, png_destroy_write_struct,
-  LIBS="$LIBS -lpng -lz", HAVE_PNG="no", -lz -lm)
+  LIBS="-lpng $LIBS -lz -lm", HAVE_PNG="no", -lz -lm)
 if test "x$HAVE_PNG" = xyes; then
   AC_DEFINE(HAVE_LIBPNG, 1, [Define if you have libpng])
 fi
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -19,4 +19,4 @@ EXTRA_DIST = \
 INCLUDES = -I$(top_srcdir)/src
 
 LDADD = $(top_builddir)/src/libzvbi.la \
-	$(PTHREAD_LIB) -lm $(PNG_LIB)
+	$(PTHREAD_LIB) $(PNG_LIB) -lm
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -262,7 +262,7 @@ EXTRA_DIST = \
 
 INCLUDES = -I$(top_srcdir)/src
 LDADD = $(top_builddir)/src/libzvbi.la \
-	$(PTHREAD_LIB) -lm $(PNG_LIB)
+	$(PTHREAD_LIB) $(PNG_LIB) -lm
 
 all: all-am
 
