title: Compiling multiple c++ files doesn't work with certain file names
body: <p>I am trying to compile multiple .cpp files, using a Makefile with <em>make</em>. I have a .cpp file containing the main function, in the other .cpp file a basic class (for every doubt I'll put all the code i'm using down here).
  Example of names used to make it compile or to make it not compile:</p>
  <p>-it works by having them named &quot;prova.cpp&quot;(contains the main function) and &quot;pa.cpp&quot;(contains the class) (below the commands done by the Makefile)</p>
  <pre><code>gioele@GioPC-U:~/Dev/Cpp/Exercises/666prova$ make
  g++ -g -Wall -c src/prova.cpp -o obj/prova.o
  g++ -g -Wall -c src/pa.cpp -o obj/pa.o
  g++ -g -Wall obj/prova.o -o bin/provaBin
  </code></pre>
  <p>-it <strong>doesn't</strong> work by having them named &quot;ciao.cpp&quot;(contains the main function) and &quot;pa.cpp&quot;(contains the class)</p>
  <pre><code>gioele@GioPC-U:~/Dev/Cpp/Exercises/666prova$ make
  g++ -g -Wall -c src/pa.cpp -o obj/pa.o
  g++ -g -Wall -c src/ciao.cpp -o obj/ciao.o
  g++ -g -Wall obj/pa.o -o bin/provaBin
  /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
  (.text+0x24): undefined reference to `main'
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:15: bin/provaBin] Errore 1
  </code></pre>
  <p>I think the problem is with the order of the files inside the Makefile. When it doesn't work is because is trying to get a binary from the .o without the main function. No idea on how to resolve.</p>
  <p>The file with the main method:</p>
  <pre><code>#include &lt;iostream&gt;
  
  int main() {
      std::cout &lt;&lt; &quot;Hello world!&quot; &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  <p>The class file:</p>
  <pre><code>class Class {
  public:
      int x;
      int y;
  };
  </code></pre>
  <p>The Makefile (still learning to work with Makefiles, probably the problem is here, any advice to make a Makefile of this kind better is appreciated, or if I am using something not properly):</p>
  <pre><code>CC=g++
  CFLAGS=-g -Wall
  OBJ=obj
  SRC=src
  BINDIR=bin
  BIN=$(BINDIR)/provaBin
  
  SRCS=$(wildcard $(SRC)/*.cpp)
  OBJS=$(patsubst $(SRC)/%.cpp, $(OBJ)/%.o, $(SRCS))
  
  all: $(BIN)
  
  $(BIN): $(OBJS)
      $(CC) $(CFLAGS) $&lt; -o $@
  
  $(OBJ)/%.o: $(SRC)/%.cpp
      $(CC) $(CFLAGS) -c $&lt; -o $@
  
  clean:
      $(RM) $(BINDIR)/* $(OBJ)/*
  </code></pre>
  <p>Thank you in advance.</p>