diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index a67f456904..0a4ec2cc5b 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -18,5 +18,8 @@ PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo testlo64
 
 all: $(PROGS)
 
+$(PROGS): $(addsuffix .o, $(PROGS))
+	$(CC) $@.o -o $@ $(LDFLAGS)
+
 clean distclean maintainer-clean:
 	rm -f $(PROGS) *.o
