Windows 에 vscode 를 install 하는 경우 아래에 접속하여 PC 환경에 맞게 진행하면된다.
참고로 User Mode 는 윈도즈 해당 사용자에서만 가능하며, System Mode 경우 해당사용자가 아니여도 사용 가능하다.
https://code.visualstudio.com/download
Download Visual Studio Code - Mac, Linux, Windows
Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.
code.visualstudio.com
한글 팩을 원한다면 ctl + shift + x 키로 아래와 같이 install 하고
c / c++ 를 사용할 예정이므로 c++ 도 install 진행한다.
VScode 는 Edit 전용으로 컴파일러를 지원하지는 않는다. 따라서 윈도즈에서 GCC G++ 을 사용해야 되는데 그걸 assist 해 주는 녀석이 바로 MinGW 이다. ㅎㅎ
https://sourceforge.net/projects/mingw/files/
MinGW - Minimalist GNU for Windows - Browse Files at SourceForge.net
×
sourceforge.net
아래와 같이 진행을 하면된다.
그 다음이 중요한데.. 바로 아래창에서 오른쪽 마우스로 설치할 항목을 설정한다.
asys-base 는 리눅스와 유사한 환경에서 프로그래밍 하고싶으면 설정하면 된다.
그 다음 좌측 상단에 installation 을 클릭 후 Apply 를 누르면 해당 항목에 대한 install 이 진행된다.
설치 완료 후 윈도즈에서 gcc g++ 컴파일러를 사용하려면 환경변수를 설정해줘야 한다.
시스템 변수에만 해주면된다. system mode install 을 했지~
정상적으로 환경 설정이 되었다면 windows + r 키를 눌러 cmd 에
위와 같다면 일단은 성공!한거다.,
VScode 로 돌아가 아래와 같이 파일을 생성해주고 ctl + shift + b 를 하면 tasks.json 파일을 만들 수 있다.
1. c++ configration <- 초기작업으로 컴파일을 불러와준다고 보면? 된다.
2. tasks.json <-batch file 과 같은 개념으로 컴파일을 위한 환경 설정이다.
3. launch.json <- 디버깅을 위한 설정으로 g++ GDB 를 선택한다.
3. key 설정
아래는 tasks.json 을 아래와 같이 해준다. ctl+shift+B 할시 gcc, g++ 을 택하게 된다.
{
"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}"
]
}
]
}
아래는 키 바인딩이다. 컴파일과 실행을 아래키를 통해 tasks.json을 가능케 해준다. ㅎㅎ
//컴파일
{ "key": "ctrl+alt+c", "command": "workbench.action.tasks.build" },
//실행
{ "key": "ctrl+alt+r", "command": "workbench.action.tasks.test" }
'VSCode' 카테고리의 다른 글
[VSCode] Visual Studio Code 및 C언어 관련 단축키 모음 (0) | 2021.11.09 |
---|