I'm having issue compile with make using a Makefile and g++. I have a simple header and source file for a class along with main. I'm unable to get it to compile with the error,
g++ -o Hello.o hello.cpp
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [Makefile:5: Hello.o] Error 1
I'm just confused about how g++ links and compiles files, having always used an IDE. I'd like to be able to control that myself and am having a difficult time understanding how it all works.
You missed the -c argument to produce an object file. Without it gcc tries to link a complete executable. You also need one more makefile rule to link both object files into an executable.