title: makefile "no such file or directory"
body: <p>I am trying to compile a C++ program using make. After reading quite a few tutorials, I have come upon the following make file.</p>
  
  <p>It reads source files from src directory, puts objects in the build directory, and puts the exe in the bin directory.</p>
  
  <p>When I try running the following makefile, I get the subsequent error.</p>
  
  <pre><code>CC := g++
  CFLAGS := -g -O2
  BIN_DIR := /bin
  BUILD_DIR := /build
  SRC_DIR := /src
  TARGET := wavfiletool.exe
  SOURCES  := $(wildcard $(SRC_DIR)/*.c)
  OBJECTS  := $(SOURCES:$(SRCDIR)/%.cpp=$(BUILD_DIR)/%.o)
  
  $(BIN_DIR)/$(TARGET): $(OBJECTS)
      $(CC) $@ $(CFLAGS) $(OBJECTS)
  
  $(OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
      @$(CC) $(CFLAGS) -c $&lt; -o $@
  </code></pre>
  
  <blockquote>
    <p>++ /bin/wavfiletool.exe -g -O2  g++: error: /bin/wavfiletool.exe: No such file or directory g++: fatal error: no input files compilation
    terminated. make: *** [/bin/wavfiletool.exe] Error 1 [Finished in 0.1s
    with exit code 2]</p>
  </blockquote>
  
  <p>UPDATE:</p>
  
  <p>I have edited the makefile. One typo in the previous version was that I have .c when I am using .cpp and c++. I am now getting a different error.</p>
  
  <p>UPDATED MAKEFILE</p>
  
  <pre><code>CC := g++
  CFLAGS := -g -O2
  BIN_DIR := bin
  BUILD_DIR := build
  SRC_DIR := src
  TARGET := wavfiletool.exe
  SOURCES  := $(wildcard $(SRC_DIR)/*.cpp)
  OBJECTS  := $(SOURCES:$(SRCDIR)/%.cpp=$(BUILD_DIR)/%.o)
  
  $(BIN_DIR)/$(TARGET): $(OBJECTS)
      $(CC) $(OBJECTS) $(CFLAGS)  -o $@ 
  
  $(OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
      @$(CC) $(CFLAGS) -c $&lt; -o $@
  </code></pre>
  
  <p>new error</p>
  
  <pre><code>makefile:13: target `src/WavFile.cpp' doesn't match the target pattern
  makefile:13: target `src/WavFileTool.cpp' doesn't match the target pattern
  g++ src/WavFile.cpp src/WavFileTool.cpp -g -O2  -o bin/wavfiletool.exe 
  </code></pre>