QT|QML
[C++ QT QML] Visual Studio Code에서 Makefile 만들기 버전[1](Windows/Ubuntu)
donggyu1998
2021. 6. 14. 14:49
반응형
💡 MinGW 설치 및 설정
https://sourceforge.net/projects/mingw-w64/files/
x86_64-8.1.0-release-posix-seh-rt_v6-rev0 라는 파일이 생길겁니다.
알집을 풀어주세요. 그 후 아래 사진처럼 C드라이브에 넣어주세요.
C드라이브에 다 넣으셨다면 변수를 설정해주세요.
C:\mingw64\bin 입니다.
이렇게 나오면 설정되었습니다.
💡 vscode로 코드 작성
hello.h
#include <stdio.h>
void print_hello();
hello.c
#include "hello.h"
void print_hello()
{
printf("hello\n");
}
makefile
CC = gcc
CFLAGS = -c -g #소스 코드 컴파일 옵션 추가하기 위해 사용
LDFLAGS =
OBJECTS = main.o hello.o
run: all
program
# 우분투라면 program이 ./program으로
# hello.c main.c 각각 오브젝트 파일 (*.o)로 컴파일한 후, 오브젝트 파일을 합쳐서 program 실행파일 생성
all: program
program : $(OBJECTS)
$(CC) $(LDFLAGS) -o program $(OBJECTS)
main.o : main.c
$(CC) $(CFLAGS) main.c
hello.o : hello.c
$(CC) $(CFLAGS) hello.c
json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "mingw32-make", // 우분투에서 사용 make로 변경
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
컨트롤 + 시프트 + B로 실행 !
반응형