본문 바로가기
IT/초기세팅

C언어 컴파일(Mac OS)

by 어센트 2020. 9. 18.

1. Xcode로 컴파일

gcc 컴파일러 설치

xcode설치 후

$ xcode-select --install
  1. Xcode 실행
  2. Create a new Xcode Project
  3. mac OS → Command Line Tool 선택
  4. Languange C 선택

 

참고자료

MAC 에서 C언어 코딩해보자

 

MAC 에서 C언어 코딩해보자

안녕하세요 강민성입니다. 6월달 쯤에 선배의 추천으로 mac을 구입했는데요, 아무래도 20년 넘게 window운영체제만 사용하다보니 많이 어색하고 낯설더라고요. 하지만 2~3달 쓰니까 이제는 다시 wind

ssungkang.tistory.com

2. VScode로 컴파일

Mac에서 VSCode C/C++ 세팅

 

Mac에서 VSCode C/C++ 세팅

오늘은 C/C++ 공부에 앞서 VSCode를 기반으로한 개발환경 세팅을 해보려고 합니다. 우선 맥에 VSCode를 깔아주세요. VSCode 설치 주소 https://code.visualstudio.com Visual Studio Code - Code Editing. Redefin..

csdiary.tistory.com

  1. C/C++ 익스텐션 설치

  2. 빌드 시 task.json 수정

    .vscode 내부에 있는 task.json

     // // 
    
     { // See https://go.microsoft.com/fwlink/?LinkId=733558 
         // for the documentation about the tasks.json format 
         "version": "2.0.0", "tasks": [
             {
                 "type": "shell",
                 "label": "g++ build active file",
                 "command": "/usr/bin/g++",
                 "args": [
                     "-g",
                     "${file}",
                     "-o",
                     "${fileDirname}/${fileBasenameNoExtension}.out"
                 ],
                 "options": {
                     "cwd": "/usr/bin"
                 },
                 "problemMatcher": [
                     "$gcc"
                 ],
                 "group": "build"
             },
             {
                 "type": "shell",
                 "label": "C/C++: g++ build active file",
                 "command": "/usr/bin/g++",
                 "args": [
                     "-g",
                     "${file}",
                     "-o",
                     "${fileDirname}/${fileBasenameNoExtension}"
                 ],
                 "options": {
                     "cwd": "${workspaceFolder}"
                 },
                 "problemMatcher": [
                     "$gcc"
                 ],
                 "group": {
                     "kind": "build",
                     "isDefault": true
                 }
             }
         ] }

launch.json

{
    "version": "0.2.0",
    "configurations": [

        {
            "type": "lldb",
            "request": "launch",
            "name": "Lldb debug",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "cwd": "${workspaceRoot}"
        }
    ]
}

'IT > 초기세팅' 카테고리의 다른 글

GDB사용을 위한 Mac 환경 설정  (0) 2020.09.18
터미널 세팅 (Oh my zsh)  (0) 2020.09.18
VSCode Extension  (0) 2020.09.18
파이썬 가상환경에서 실행  (0) 2020.09.18
IntelliJ  (0) 2020.09.18