From 57ce198d71f0c0a2cc35539da91bae3afe8d6e84 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 12 Jul 2023 12:46:18 -0400 Subject: [PATCH] Move libraries to the end of the link line to avoid errors like: ``` g++ -lssl -lcrypto -o sigtool main.o hash.o macho.o signature.o commands.o /usr/bin/ld: hash.o: in function `SigTool::SHA256Hash::SHA256Hash(unsigned char const*, unsigned long)': hash.cpp:(.text+0xcc): undefined reference to `SHA256' collect2: error: ld returned 1 exit status make: *** [Makefile:18: sigtool] Error 1 ``` The link line is updated to be something like: ``` g++ -o sigtool main.o hash.o macho.o signature.o commands.o -lssl -lcrypto ``` --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 46ccc4a..38bb504 100644 --- a/Makefile +++ b/Makefile @@ -12,13 +12,13 @@ CODESIGN_SRCS = codesign.cpp $(COMMON_SRCS) CODESIGN_OBJS := $(CODESIGN_SRCS:.cpp=.o) CPPFLAGS := -I vendor $(shell $(PKG_CONFIG) --cflags openssl) -LDFLAGS := $(shell $(PKG_CONFIG) --libs openssl) +LIBS := $(shell $(PKG_CONFIG) --libs openssl) sigtool: $(SIGTOOL_OBJS) - $(CXX) $(LDFLAGS) -o $@ $^ + $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) codesign: $(CODESIGN_OBJS) - $(CXX) $(LDFLAGS) -o $@ $^ + $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) .PHONY: install install: sigtool codesign