From 84feb345eaf2a73abe4d1f9d2155edc058a8e570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Sat, 8 Jul 2023 22:26:27 +0000 Subject: Makefile: fix undefined references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling gives the following error, since the library is specified before the local objects: $ make […] cc -lpng16 build/main.o build/ql.o build/loadpng.o -o build/qlprint /usr/bin/ld: build/loadpng.o: in function `loadpng': …/src/loadpng.c:30: undefined reference to `png_sig_cmp' /usr/bin/ld: …/src/loadpng.c:35: undefined reference to `png_create_read_struct' /usr/bin/ld: …/src/loadpng.c:39: undefined reference to `png_create_info_struct' /usr/bin/ld: …/src/loadpng.c:43: undefined reference to `png_create_info_struct' […] collect2: error: ld returned 1 exit status make: *** [Makefile:28: build/qlprint] Error 1 After reordering: $ make […] cc build/main.o build/ql.o build/loadpng.o -lpng16 -o build/qlprint --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d170eb3..767c268 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ build/%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ build/qlprint: $(OBJS) - $(CC) $(LDFLAGS) $^ -o $@ + $(CC) $^ $(LDFLAGS) -o $@ $(OBJS): $(wildcard include/*) Makefile -- cgit v1.2.1