그렇게 빠르게 프로젝트에 진입한 편은 아니지만...
그래도 이제 본격적으로 프로그래밍 언어인 c로 시작이다! (아마 첫번
째 시험도, 팀프로젝트도 c로 한다는 소문이 있으니 쉘에 집착하기 보다는..)
먼저 나 또한 생소한 맥os에서 개발환경을 구축해보는 것이기 때문에 글로 남겨둔다.
순서를 먼저 적어보자면,
1. gcc 설치하기 (간략하게 설명하자면 사람이 작성하는 c언어를 컴퓨터가 이해할 수 있는 기계어로 바꿔주는)
macOS는 /usr/local/bin 에 gcc가 내장되어 있기 때문엥 커맨드창에서 쉽게 할 수 있다.
(확인방법 : 커맨드창에서 gcc -v를 쳐보자 - 왠지 느낌이 clang을 덮어씌워놓은 것 같은데.. 아마 맞을 듯)
참조 : (윈도우용) https://sourceforge.net/projects/mingw-w64/files/latest/download
2. 비주얼스튜디오코드(이하 vsc) 맥용 설치하기(IDE임. 약자는 까먹었는데.. 암튼 코딩을 편리하게 해주는 어플리케이션)
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
2-1. vsc용 익스텐션 설치 - c언어 코딩 스탠다드 룰
https://marketplace.visualstudio.com/items?itemName=evilcat.norminette-42
norminette-42 - Visual Studio Marketplace
OverviewQ & ARating & Review Norminette Vscode Simple decorator for vscode user that use norminette command at 42/101 and inject errors of the current opened file in the vscode editor. Setting Default setting is "norminette.command": "norminette", "normine
marketplace.visualstudio.com
2-2. vsc용 익스텐션 설치2 - 42 라피신용 헤더파일 만들기
https://marketplace.visualstudio.com/items?itemName=kube.42header
42 Header - Visual Studio Marketplace
OverviewQ & ARating & Review This extension provides the 42 header integration in VS Code. # **************************************************************************** # # # # ::: :::::::: # # vscode-42header :+: :+: :+: # # +:+ +:+ +:+ # # By: kube +#+
marketplace.visualstudio.com
3. vsc 실행시켜서 프로젝트 생성
3-1. 인스톨
확장자가 .c나 .h로 파일을 만든다면, 오른쪽 아래에 C/C++ 확장 권장 메시지 박스가 뜬다면 Install을 클릭하여 설치.
3-2. 설정
Command + Shift + P를 누룬 후 c/c++을 입력하면 보이는 C/C++ : Edit Configurations(UI)를 선택한다.
설정한다. 대충 usr/bin/gcc 를 입력하고 밑에 gcc x64를 선택하면 될 듯
3-3. task.json 만들기(그냥 인터넷에서 돌아다니는 것 다운 받은 다음에 넣어두어도 괜찮음)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label":"save and compile for C",
"type": "shell",
"command": "gcc",
"args": [
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"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
}
},
"group": "build"
},
{
"label": "execute",
"command": "cd ${fileDirname} && ./${fileBasenameNoExtension}",
"group": "test"
}
]
}
4. 단축키를 설정 (왼쪽 위 바에서 Code > Preferences > Keyboards Shortcuts)
// Place your key bindings in this file to override the defaults
[
//save and compile for C
{ "key": "ctrl+alt+c", "command": "workbench.action.tasks.build" },
//excute
{ "key": "ctrl+alt+r", "command": "workbench.action.tasks.test" }
]
5. 뚜둥!! 대망의 실행해보기! (미리 코드는 만들어놔야되고..)
위에서 설정한대로 Ctrl + Alt + C (컴파일) 누르면
그 위에위에서 설정한 대로 save and compile for C 가 나오므로 선택.
컴파일 문제가 없이 exe파일이 생성된다면 또 위에서 설정한대로 Ctrl + Alt + R 누르면
excute 가 나오므로 선택.
6. 결과값 확인
아마 밑에 터미널에서 나올거임.
난 아직 안해봄..
심지어 아직 프로젝트 1번 문제 보지도 않았는데 옆에분이 터미널에서 vi로 하시면서 물어보시길래 깜놀..
이상 D-22, 의도하지 않았었지만 드디어 제대로 쓰게 된 기술문서 다운 라피신 블로그 끝.
'코드쓰기 카테고리 > 라 피신' 카테고리의 다른 글
C언어 <string.h>에 있는 라이브러리 (0) | 2020.01.29 |
---|---|
터미널에서 write 메뉴얼 찾는 법은 [man pwrite] (0) | 2020.01.29 |
D-18, 이제 라피신 일주일 째. 우리는 한일전을 하고 있다 (2) | 2020.01.27 |
D-19 설날이지만 라피신 (0) | 2020.01.27 |
첫 시험 D-20 (0) | 2020.01.27 |