C “的任务配置”;“保持清洁”;不';t在Visual Studio 2017工作
我写了一个简单的程序:C “的任务配置”;“保持清洁”;不';t在Visual Studio 2017工作,c,visual-studio,makefile,C,Visual Studio,Makefile,我写了一个简单的程序: void nothing(); CC = gcc CC_FLAGS = -g EXEC = run SOURCES = $(wildcard *.c) OBJECTS = $(SOURCES:.c=.o) $(EXEC): $(OBJECTS) $(CC) $(OBJECTS) -o $(EXEC) %.o: %.c $(CC) -c $(CC_FLAGS) $< -o $@ clean: rm
void nothing();
CC = gcc
CC_FLAGS = -g
EXEC = run
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
$(EXEC): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.c
$(CC) -c $(CC_FLAGS) $< -o $@
clean:
rm -f $(EXEC) $(OBJECTS)
{
"version": "0.2.1",
"tasks": [
{
"taskName": "BUILD",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make",
"type": "default"
},
{
"taskName": "CLEAN",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make clean",
"type": "default"
}
]
}
'"make clean"' is not recognized as an internal or external command,
operable program or batch file.
main.c:
#include "main.h"
void nothing(){}
int main(){
nothing();
return 0;
}
void nothing();
CC = gcc
CC_FLAGS = -g
EXEC = run
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
$(EXEC): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.c
$(CC) -c $(CC_FLAGS) $< -o $@
clean:
rm -f $(EXEC) $(OBJECTS)
{
"version": "0.2.1",
"tasks": [
{
"taskName": "BUILD",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make",
"type": "default"
},
{
"taskName": "CLEAN",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make clean",
"type": "default"
}
]
}
'"make clean"' is not recognized as an internal or external command,
operable program or batch file.
main.h:
void nothing();
CC = gcc
CC_FLAGS = -g
EXEC = run
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
$(EXEC): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.c
$(CC) -c $(CC_FLAGS) $< -o $@
clean:
rm -f $(EXEC) $(OBJECTS)
{
"version": "0.2.1",
"tasks": [
{
"taskName": "BUILD",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make",
"type": "default"
},
{
"taskName": "CLEAN",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make clean",
"type": "default"
}
]
}
'"make clean"' is not recognized as an internal or external command,
operable program or batch file.
到目前为止,使用这个通用的Makefile
编译并运行它:
void nothing();
CC = gcc
CC_FLAGS = -g
EXEC = run
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
$(EXEC): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.c
$(CC) -c $(CC_FLAGS) $< -o $@
clean:
rm -f $(EXEC) $(OBJECTS)
{
"version": "0.2.1",
"tasks": [
{
"taskName": "BUILD",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make",
"type": "default"
},
{
"taskName": "CLEAN",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make clean",
"type": "default"
}
]
}
'"make clean"' is not recognized as an internal or external command,
operable program or batch file.
BUILD
的任务有效,但对于CLEAN
我得到:
void nothing();
CC = gcc
CC_FLAGS = -g
EXEC = run
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
$(EXEC): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.c
$(CC) -c $(CC_FLAGS) $< -o $@
clean:
rm -f $(EXEC) $(OBJECTS)
{
"version": "0.2.1",
"tasks": [
{
"taskName": "BUILD",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make",
"type": "default"
},
{
"taskName": "CLEAN",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make clean",
"type": "default"
}
]
}
'"make clean"' is not recognized as an internal or external command,
operable program or batch file.
您知道如何修复
CLEAN
的任务,使其按照我的要求执行make CLEAN吗?作为“command”
的值给出的字符串被解释为单个命令。要向命令发送参数,如clean
,模式提供了提供参数数组的可能性。在您的情况下,它将如下所示:
void nothing();
CC = gcc
CC_FLAGS = -g
EXEC = run
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
$(EXEC): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.c
$(CC) -c $(CC_FLAGS) $< -o $@
clean:
rm -f $(EXEC) $(OBJECTS)
{
"version": "0.2.1",
"tasks": [
{
"taskName": "BUILD",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make",
"type": "default"
},
{
"taskName": "CLEAN",
"appliesTo": "/",
"workingDirectory": "${workspaceRoot}",
"command": "make clean",
"type": "default"
}
]
}
'"make clean"' is not recognized as an internal or external command,
operable program or batch file.
"command": "make",
"args": [ "clean" ],