Kminseo

Ubuntu에서 vscode를 사용하는 개발환경 구축 본문

기타

Ubuntu에서 vscode를 사용하는 개발환경 구축

Kminseo 2019. 10. 15. 00:07

 

Ubuntu에서 vscode를 사용하는 개발환경 구축

  1. 컴파일러 설치하기확인하기 위해 $ gcc -help로 체크해보기 대충 뭐가 나온다.
  2. $ sudo apt-get install build-essential
  3. vscode 설치

[vscode 주소]https://code.visualstudio.com/

에서 deb 파일 을 설치
$ sudo dpkg -i '파일명'으로 설치 가능

귀찮으면 ubuntu software center 에서 vscode를 검색해서 설치가 가능하다.

  1. C, C++ 컴파일용 플로그인 설치
  • Ctrl + Shift + X를 눌러 확장플로그인 검색창에 C++을 검색하면 C/C++확장 플러그인 설치
  1. 작업 환경 구성
  • Ctrl + Shift + E눌러 탐색창으로 VSCode 프로젝트를 구성할 작업폴더 지정
  • 작업표시줄에서 Terminal > Configure Default Build Task > C/C++:g++ build active file
  • tasks.json 파일이 생성되며, 아래 코드를 복사+붙여넣기
```
    {
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
        ]
    }
```
  1. 빌드 및 실행
    #include<iostream>
    
     int main()
     {
         std::cout<<"hello"<<std::endl;
         return 0;
     }
    
  2. F5를 눌러 실행을 해줍니다.

[참조] Youtube : https://www.youtube.com/watch?v=QbWe-qHEOfc
[참조] VJ:code : https://yjcode.tistory.com/1?category=811393

Comments