title: Adding INCLUDE, LIB and LD_LIBRARY_PATH in Makefile
body: <p>I am writing a new Makefile and would like to copy my object files in obj/ folder. I tried to add OBJ directory folder but it is not picking up. I am sure I am missing something. For now I moved .o files from src/ folder to obj/ folder after compilation.</p>
  
  <p>Could you please let me know how to add INCLUDES and LIB_INCLUDES in this makefile. As include path is not there in Makefile it is expecting me to specify complete (relative) path in source code while including header file.</p>
  
  <p>Also, I would like to include some external libraries (LD_LIBRARY_PATH) statically in my executable, so how can I specify those in Makefile:</p>
  
  <pre class="lang-none prettyprint-override"><code>APPNAME := MyApp.x
  SOURCE_DIR   := ./src
  INCLUDE_DIR  := ./include
  OBJECT_DIR   := ./obj
  BIN_DIR      := ./bin
  
  CC := g++
  CCFLAGS := -g -Wall
  
  SRCFILES     := $(wildcard $(SOURCE_DIR)/*.cpp)
  INCLUDES     := $(INCLUDE_DIR)
  LIB_INCLUDES := $(INCLUDE_DIR)
  OBJECTS      := $(patsubst %.cpp, %.o, $(SRCFILES))
  
  all: $(APPNAME)
  
  $(APPNAME): $(OBJECTS)
          $(CC) $(CCFLAGS) $(LDFLAGS) -o $(BIN_DIR)/$(APPNAME) $(OBJECTS) $(LDLIBS)
          \mv -f $(SOURCE_DIR)/*.o obj
  
  depend: .depend
  
  .depend: $(SRCFILES)
          rm -f ./.depend
          $(CC) -I$(INCLUDES) $(CCFLAGS) $^&gt;&gt;./.depend;
  
  clean:
          rm -f $(OBJECTS)
  
  dist-clean: clean
          rm -f *~ .depend
  
  include .depend
  </code></pre>
  
  <p>Created separate thread for this request - lubgr.</p>