【发布时间】:2021-02-03 03:44:54
【问题描述】:
我想问一下以下 Makefile 是否正确编写,因为程序似乎无法正确编译,但我不确定是 makefile 还是代码有问题:
CC = /usr/bin/gcc
CFLAGS = -g -Wall -Wextra -Werror -pthread
DEPS = config.h shmHandling.h gameboard.h thinker.h strTools.h performConnection.h main.h
OBJ = main.o config.o shmHandling.o gameboard.o thinker.o strTools.o performConnection.o
# Link all .o files to program
%.o: %.c $(DEPS)
@echo "-----------------------"
@echo "Linking object files"
$(CC) -o -c $@ $< $(CFLAGS)
sysprak-client: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS)
# Compile everything and run it with CL params
.PHONY: play
play: sysprak-client
@echo "-----------------------"
@echo "Launching sysprak-client with GameID: $(GAME_ID)"
./sysprak-client -g $(GAME_ID) -p $(PLAYER)
.PHONY: clean
clean:
-rm *.o $(OBJ)
谢谢!
【问题讨论】:
-
运行make时屏幕上显示什么?
-
我得到了很多错误,但代码似乎在另一台没有 make 文件的计算机上运行 % make /usr/bin/gcc -g -Wall -Wextra -Werror -pthread -c - o gameboard.o gameboard.c gameboard.c: In function 'isEmpty': gameboard.c:7:8: error: 'DEBUGL' undeclared (first use in this
-
每个错误都与游戏板文件相关联
-
你在哪里声明
DEBUGL? -
如果你运行 make,所有的命令都会被打印出来。您可以手动检查并尝试这些命令中的每一个,以找出错误所在。