title: make: *** No rule to make target 'main.c', needed by 'main.o'. Stop
body: <p>I have 3 .c files in my src directory and i have a Makefile in the parent directory of src. All my c files just use standard header files.
  The error i am getting while using make command is</p>
  
  <blockquote>
    <p>make: *** No rule to make target 'main.c', needed by 'main.o'.  Stop.</p>
  </blockquote>
  
  <p>I tried all the tweaks that people have mentioned here and there but could not solve the problem. help please.</p>
  
  <p>i tried including vpath directive too.</p>
  
  <h1><strong>Makefile</strong></h1>
  
  <pre><code>vpath src
  vpath inc
  CFLAGS=-I inc
  output: main.o helloExec.o execDemo.o
      $(CC) -o $(CFLAGS) $&lt;
  
  main.o: main.c
      $(CC) -c $(CFLAGS) $&lt; $(CFLAGS)
  helloExec.o: helloExec.c
      $(CC) -c $(CFLAGS) $&lt; $(CFLAGS)
  execDemo.o: execDemo.c
      $(CC) -c $(CFLAGS) $&lt; $(CFLAGS)
  clean:
      rm -f *.o output
  </code></pre>
  
  <h1><strong>main.c</strong></h1>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      printf("hello\n");
      return 0;
  }
  </code></pre>
  
  <h1><strong>execDemo.c</strong></h1>
  
  <pre><code>#include&lt;stdlib.h&gt;
  #include&lt;unistd.h&gt;
  
  int main()
  {
      printf("execDemo with pid = %d\n", getpid());
      return 0;
  }
  </code></pre>
  
  <h1><strong>helloExec.c</strong></h1>
  
  <pre><code>#include&lt;stdlib.h&gt;
  #include&lt;unistd.h&gt;
  
  int main()
  {
      printf("helloExec with pid = %d\n", getpid());
      return 0;
  }
  </code></pre>