diff --git a/Makefile b/Makefile
index dfdce1d83d8b8cdfc79d47f8ae4cc5e6551f905b..644691969e8324f40ad8c3312a9067c0564b60f5 100644
--- a/Makefile
+++ b/Makefile
@@ -262,6 +262,8 @@ LDFLAGS += -fPIC
 endif
 
 INCLUDES = . include $(GENDIR)
+LDFLAGS += -Llibs/$(CONFIG)
+
 ifeq ($(SYSTEM),Darwin)
 ifneq ($(wildcard /usr/local/ssl/include),)
 INCLUDES += /usr/local/ssl/include
diff --git a/templates/Makefile.template b/templates/Makefile.template
index bc8f1bb1d071b7db97b864ae18bf0bded5a5acb0..1422150d0d9c3a5b8bf8aa044bbb1aad631237e0 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -276,6 +276,8 @@ LDFLAGS += -fPIC
 endif
 
 INCLUDES = . include $(GENDIR)
+LDFLAGS += -Llibs/$(CONFIG)
+
 ifeq ($(SYSTEM),Darwin)
 ifneq ($(wildcard /usr/local/ssl/include),)
 INCLUDES += /usr/local/ssl/include