title: Include library path in the makefile
body: <p>My makefile looks as follows</p>
  
  <pre><code>program_NAME := myprogram
  program_C_SRCS := $(wildcard *.cc)
  program_C_OBJS := ${program_C_SRCS:.cc=.o}
  program_OBJS := $(program_C_OBJS) 
  program_INCLUDE_DIRS := ../INCLUDE
  program_LIBRARY_DIRS := 
  program_LIBRARIES :=
  CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
  LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
  LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
  
  .PHONY: all clean distclean
  
  all: $(program_NAME)
  
  $(program_NAME): $(program_OBJS)
  $(LINK.cc) $(program_OBJS) -o $(program_NAME)
  
  clean:
      @- $(RM) $(program_NAME)
      @- $(RM) $(program_OBJS)
  
  distclean: clean
  </code></pre>
  
  <p>I have created a library <code>stack.a</code> in some path <code>/home/Desktop/kk/stack</code>.
  I want to include this library into my makefile so that during linking it should be picked up from that path. </p>
  
  <p>I tried to give:</p>
  
  <pre><code>program_LIBRARY_DIRS := /home/Desktop/kk/stack
  </code></pre>
  
  <p>and in linking step I gave:</p>
  
  <pre><code>$(LINK.cc) $(program_OBJS) stack.a -o $(program_NAME)
  </code></pre>
  
  <p>But the makefile is not able to pick up the library from the path mentioned.</p>
  
  <p>Instead, if I directly give:</p>
  
  <pre><code>$(LINK.cc) $(program_OBJS) /home/Desktop/kk/stack/stack.a -o $(program_NAME)
  </code></pre>
  
  <p>it works perfectly.</p>
  
  <p>Please help me how to include this library path so that I do not have to give the location of library in link command.</p>