Makefile
Solved
next
Posted messages
43
Registration date
Status
Membre
-
next Posted messages 43 Registration date Status Membre -
next Posted messages 43 Registration date Status Membre -
Hello everyone, I created a Makefile and I have several problems...
When I try to place an @echo I get the message
Makefile:16: *** missing separator (did you mean TAB instead of 8 spaces?). Stopped.
or even for clean I get the message:
make: *** No rule to make target « rm », needed for « clean ». Stopped.
here is my code:
OBJS = main.o command.o
LINKOBJET = main.o command.o
BIN = ircweb
CC = gcc
CFLAGS = -W -Wall -ansi -pedantic -D_REENTRANT -std=c99
LDFLAGS = -I /usr/include/mysql/ -L /usr/lib/mysql/ -lmysqlclient -lpthread
RM = rm -f
all: $(BIN) clean
clean: ${RM} $(OBJS) *.c~
$(BIN): $(OBJS)
$(CC) $(LINKOBJET) -o $(BIN) $(LDFLAGS)
main.o: main.c
$(CC): $(CFLAGS) -c main.c -o main.o
command.o: command.c
$(CC): $(CFLAGS) -c command.c -o command.c
@echo end of compilation.
Can you help me?
When I try to place an @echo I get the message
Makefile:16: *** missing separator (did you mean TAB instead of 8 spaces?). Stopped.
or even for clean I get the message:
make: *** No rule to make target « rm », needed for « clean ». Stopped.
here is my code:
OBJS = main.o command.o
LINKOBJET = main.o command.o
BIN = ircweb
CC = gcc
CFLAGS = -W -Wall -ansi -pedantic -D_REENTRANT -std=c99
LDFLAGS = -I /usr/include/mysql/ -L /usr/lib/mysql/ -lmysqlclient -lpthread
RM = rm -f
all: $(BIN) clean
clean: ${RM} $(OBJS) *.c~
$(BIN): $(OBJS)
$(CC) $(LINKOBJET) -o $(BIN) $(LDFLAGS)
main.o: main.c
$(CC): $(CFLAGS) -c main.c -o main.o
command.o: command.c
$(CC): $(CFLAGS) -c command.c -o command.c
@echo end of compilation.
Can you help me?
Configuration: Linux Debian Mozilla 1.8.1.10
9 réponses
After each target, each command must be on a new line and preceded by a tabulation (not a series of spaces). For more information:
https://gl.developpez.com/tutoriel/outil/makefile/
Good luck
https://gl.developpez.com/tutoriel/outil/makefile/
Good luck
Thank you, but I had already read that tutorial, and it doesn't really help me, sorry...
Could you show me how to do it on my Makefile? That would really help me understand.
Could you show me how to do it on my Makefile? That would really help me understand.
Well, I don't know, in your case it would look more like this:
(or each line is a tab)
Good luck.
OBJS = main.o command.o LINKOBJET = main.o command.o BIN = ircweb CC = gcc CFLAGS =-W -Wall -ansi -pedantic -D_REENTRANT -std=c99 LDFLAGS=-I /usr/include/mysql/ -L /usr/lib/mysql/ -lmysqlclient -lpthread RM = rm -f all: $(BIN) clean clean: ${RM} $(OBJS) *.c~ $(BIN): $(OBJS) $(CC) $(LINKOBJET) -o $(BIN) $(LDFLAGS) main.o: main.c $(CC) $(CFLAGS) -c main.c -o main.o command.o: command.c $(CC): $(CFLAGS) -c command.c -o command.c @echo end of compilation. (or each line is a tab)
Good luck.
<5> Line breaks and tabs
<6> Did you use tabs correctly:
<6> Did you use tabs correctly:
clean: <TAB>${RM} $(OBJS) *.c~ $(BIN): $(OBJS) <TAB>$(CC) $(LINKOBJET) -o $(BIN) $(LDFLAGS) ...
I just understood with your last post, actually you have to use the tab key. Because now it works without any problems, thanks again :)