Question

I'm working on learning C from a family member who's very adept as far as I know.

I'm using MingW on windows 7 with a fresh install of windows and having some difficulties getting things to work properly. I've made a make file and am using Deitel C for programmers with an introduction to C11, and have typed up the examples from the book in chapter three. I'm fairly certain I've managed to get that portion correct, and the makefile I'm using seems to be correct but it gives me a strange error that I don't understand.

C -o ex01 -O3 -Wall -Werrors -static -pedantic-errors -g main.o
make: C: Command not found
make: * [ex01] Error 127

this is the exact error I keep getting, I'm not sure if there's something wrong with the makefile or if it's something wrong with settings...

RM=rm
CC=gcc
LINK=$CC
CFLAGS = -O3 -Wall -Werrors -static -pedantic-errors -g

all: main.o ex01
clean:
(Tab)$(RM) -f main.o ex01.exe

main.o: main.c
(Tab)$(CC) -o main.o $(CFLAGS) -c main.c

ex01: main.o
(Tab)$(LINK) -o ex01 $(CFLAGS) main.o

this is almost exactly the makefile I'm using, asside from the (Tab) in place of actual tabs. I hope this is enough information to get some help, I suspect it's something wrong with my settings, I've had to set up paths to my library and gcc location. I'm just not sure where else to set up a path that could rectify this error.

Was it helpful?

Solution

@Keltar's comment nailed it exactly: LINK=$CC should be LINK=$(CC).

In make's syntax, $() is the proper way to deference a variable. The line LINK=$(CC) means set the variable LINK to whatever the CC variable is set to. After that instruction, their values will be the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top