我试图从模板制作一个makefile,这就是我所拥有的:
CFLAGS = -Wall -pedantic
LFLAGS = -lpthread
CC = gcc
OBJS = bank5.o client2.o
PROGRAM = ex2
all: bank client
ex2: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o $(PROGRAM)
bank: bank5.c
$(CC) $(CFLAGS) -c bank5.c receive_message.c send_message.c -o bank5
client: client2.c
$(CC) $(CFLAGS) -c client2.c receive_message.c send_message.c -o client2
当我尝试运行它时,我收到此错误:
gcc -Wall -pedantic -c bank5.c receive_message.c send_message.c -o bank5
gcc: fatal error: cannot specify -o with -c, -S or -E with multiple files
compilation terminated.
make: *** [bank] Error 4
这是我的 makefile 在 -Wall 和 -pedantic 之前的样子,它运行正常:
all: bank client
bank: bank5.c
gcc bank5.c receive_message.c send_message.c -o bank5 -lpthread
client: client2.c
gcc -o client2 client2.c send_message.c receive_message.c