相关疑难解决方法(0)

makefile别名

请在下面的makefile中解释$ @ $ ^ $

LIBS  = -lkernel32 -luser32 -lgdi32 -lopengl32
CFLAGS = -Wall

# (This should be the actual list of C files)
SRC=$(wildcard '*.c')

test: $(SRC)
    gcc -o $@ $^ $(CFLAGS) $(LIBS)
Run Code Online (Sandbox Code Playgroud)

makefile

3
推荐指数
1
解决办法
4039
查看次数

Makefile可以编译所有.c文件而无需指定它们

我正在尝试创建一个Makefile,它.c可以编译所有文件而无需在Makefile中每行添加文件名行.我认为这与makefile非常相似- 一次编译所有c文件.这就是我想要做的事情:

1 - 验证是否所有.c文件都来自/src其各自的.o文件/obj.如果该.o文件不存在,请从该.c文件构建它;

2 - main.exe从所有编译.o并打开它/bin.

我的Makefile:

BIN     = ./bin
OBJ     = ./obj
INCLUDE = ./include
SRC     = ./src

all:
    gcc -c "$(SRC)/Distances.c" -o "$(OBJ)/Distances.o"
    gcc -c "$(SRC)/HandleArrays.c" -o "$(OBJ)/HandleArrays.o"
    gcc -c "$(SRC)/HandleFiles.c" -o "$(OBJ)/HandleFiles.o"
    gcc -c "$(SRC)/Classifier.c" -o "$(OBJ)/Classifier.o"
    gcc -c main.c -o "$(OBJ)/main.o"
    gcc -o $(BIN)/main.exe $(OBJ)/*.o -lm

run:
    $(BIN)/main.exe

clean:
    del /F …
Run Code Online (Sandbox Code Playgroud)

c makefile

0
推荐指数
2
解决办法
1286
查看次数

标签 统计

makefile ×2

c ×1