본문 바로가기

환경/개발 환경 설정

Visual Studio Code 에서 C++ 적용

1. MinGW 설치 

위와 같이 설치 시 나오는 MinGW Installation Manager 에서 해당 Mark를 추가한다.

Installation → Apply Change → Apply 적용 시 해당 라이브러리를 다운 받는다.

2. 시스템 환경 변수 추가 

 

시스템 속성 → 환경 변수 → PATH 환경 변수 편집에 MinGW 설치경로/bin 을 추가한다.

3. Visual Studio Code 설정 

  • c/c++ 확장 라이브러리 다운로드 
  • task.json 변경
{ 
    "version": "2.0.0", 
    "runner": "terminal", 
    "type": "shell", 
    "echoCommand": true, 
    "presentation": { 
        "reveal": "always" 
    }, 
    "tasks": [ 
        //C++ 컴파일 
        { 
            "label": "save and compile for C++", 
            "command": "g++", 
            "args": [ 
                "${file}", 
                "-o", 
                "${fileDirname}/${fileBasenameNoExtension}" 
            ], 
            "group": "build", 
            //컴파일시 에러를 편집기에 반영 
            //참고:   https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher 
            "problemMatcher": { 
                "fileLocation": [ 
                    "relative", 
                    "${workspaceRoot}" 
                ], 
                "pattern": { 
                    // The regular expression.  
                    //Example to match: helloWorld.c:5:3: warning: implicit declaration of function 'prinft' 
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$", 
                    "file": 1, 
                    "line": 2, 
                    "column": 3, 
                    "severity": 4, 
                    "message": 5 
                } 
            } 
        }, 
        //C 컴파일 
        { 
            "label": "save and compile for C", 
            "command": "gcc", 
            "args": [ 
                "${file}", 
                "-o", 
                "${fileDirname}/${fileBasenameNoExtension}" 
            ], 
            "group": "build", 
            //컴파일시 에러를 편집기에 반영 
            //참고:   https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher 
            "problemMatcher": { 
                "fileLocation": [ 
                    "relative", 
                    "${workspaceRoot}" 
                ], 
                "pattern": { 
                    // The regular expression.  
                    //Example to match: helloWorld.c:5:3: warning: implicit declaration of function 'prinft' 
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$", 
                    "file": 1, 
                    "line": 2, 
                    "column": 3, 
                    "severity": 4, 
                    "message": 5 
                } 
            } 
        }, 
        // // 바이너리 실행(Windows) 
        { 
            "label": "execute", 
            "command": "cmd", 
            "group": "test", 
            "args": [ 
                "/C", 
                "${fileDirname}\\${fileBasenameNoExtension}" 
            ] 
        } 
    ] 
}

 

 

'환경 > 개발 환경 설정' 카테고리의 다른 글

VirtualBox 네트워크 사용법  (0) 2022.09.21