Haagenti
Haagenti

Reputation: 8144

C - Makefile error

I am just starting out with C and now I am at the part where I want to learn about Makefiles. I am starting out small but already failing ;)

I have a very simple Makefile which just compiles the main.c to a main.o and then to an executable. But I get an error saying I have a syntax error. I use g++.

The command that i use are:

g++ make Makefile << name of the make file

And the Makefile is set up like this:

main.o: main.c main.h
[TAB]   g++ -c main.c

main: main.o
[TAB]   g++ main.o -o main

Upvotes: 1

Views: 210

Answers (1)

unwind
unwind

Reputation: 399703

To run make on the Makefile (the default name), invoke the make command:

$ make

Don't try to call g++ with the makefile, the compiler knows nothing about makefiles.

EDIT: You say you don't have the make command, in a comment. Then you need to get it. :) There are several versions of make for Windows, here is GNU make (which is common in Linux and other Unix-like environments) ported to Windows.

Upvotes: 3

Related Questions