C 개발환경 구축을 위한 Windows 용 컴퍼일러 설치 및 환경설정

컴파일러를 상징하는 일러스트레이션

1. mingw-w64의 Windows용 배포판 개요

  1. (Cygwin) 유닉스 전용 라이브러리나 툴을 Windows에서 그대로 쓰고 싶을 때 유용하나, 초중량
  2. (GCC-MCF) POSIX 호환성보다는 Windows 네이티브 성능과 단순성을 중시하나, 표준 스레드 모델이 아닌 자체 모델(MCF)로 호환성 대중성 제한
  3. (LLVM-MinGW) GCC 대신 LLVM/Clang/LLD 기반으로 일부 라이브러리 호환성 문제
  4. (MinGW-W64-builds) 컴파일 결과물은 별도의 런타임 환경 없이 Windows에서 바로 실행 가능, 신속·경량·대중적
  5. (MSYS2) 최신 라이브러리와 툴을 쉽게 설치, 리눅스 스타일 개발환경 제공, 초중량
  6. (w64devkit) 매우 가볍고 휴대성 좋음, PATH 설정 불필요, 기능제한
  7. (WinLibs.com) 최신 버전 빠르게 제공, 설치 간단하나, 추가 라이브러리 설치 필요

2. 설치

2.1. 최신 Archive 버전 설치

  1. 개발자 Github niXman / mingw-builds-binaries에서 최신버전(2026.3. 현재 15.2.0-rt_v13-rev1) 다운로드
  2. 시스템 검색창에서 “시스템 환경변수 편집” 항목 검색 후 클릭
  3. “환경변수” 클릭
  4. 시스템변수 창에 Path 선택 후, 편집
  5. “새로만들기” 클릭 후 경로(C:\MinGW\bin) 입력

2.2. Install 버전 설치

  1. SourceForge에서 mingw-get-setup.exe (2026.3. 현재 mingw-w64-v11.0.0)다운로드
  2. Default 로 설치 진행
  3. MinGW Installation Manger 연 상태에서 다음 4개 항목 선택
    • mingw-developer-toolkit
    • minigw32-base
    • mingw32-gcc-g++
    • msys-base
  4. installation - Update Category 또는 Apply Changes

3. Path 설정 확인 및 실행 테스트

  1. 명령프롬프트창에서 다음 명령어로 버전 확인

    C:\Users\user>gcc -v  # 또는 gcc --version
    
    gcc (x86_64-posix-seh-rev1, Built by MinGW-Builds project) 15.2.0
    Copyright (C) 2025 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  2. 다음 소스 저장

    // Hello.c
    
    #include <stdio.h>
    
    int main(void) {
    printf("%s", "Hello, World!!");
    return 0;
    }
    
  3. 컴파일

    C:\Users\user>gcc Hello.c // a.exe 생성
    C:\Users\user>gcc -o Hello Hello.c // Hello.exe 생성
    
  4. 실행결과 확인

    C:\Users\user>./Hello.exe
    
    Hello, World!!
    

4. vscode에서 설정

4.1. launch.json 파일 생성(또는 변경)

  1. 명령팔레트(Ctrl + Shift + P) 실행

    • C/C++: Add Debug Configuration 선택
    • C/C++: gcc.exe build and debug active file 선택
  2. launch.json 파일 수정

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C/C++: gcc.exe build and debug active file",
      "type": "cppdbg",
      "request": "launch",
      // "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "program" : "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      // "cwd": "C:\\MinGW\\bin",
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      // "miDebuggerPath": "gdb.exe",
      "miDebuggerPath": "C:\\Tools\\mingw64\\bin\\gdb.exe",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        },
        {
          "description": "Set Disassembly Flavor to Intel",
          "text": "-gdb-set disassembly-flavor intel",
          "ignoreFailures": true
        }
      ],
      "preLaunchTask": "C/C++: gcc.exe build active file"
    }
  ]
}

4.2. task.json 파일 생성(또는 수정)

  1. 명령팔레트(Ctrl + Shift + P) 실행
    • Tasks: Configure Task
    • C/C++ gcc.exe build active file…
  2. task.json 파일 수정
{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: gcc.exe build active file",
      // "command": "C:\\MinGW\\bin\\gcc.exe",
      "command": "C:\\Tools\\mingw64\\bin\\gcc.exe",
      "args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}\\${fileBasenameNoExtension}.exe"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "Task generated by Debugger."
    }
  ]
}

【참고자료】