'프로그램 설치'에 해당되는 글 2건

@ 참고 : 내 기억, https://kkangeva.tistory.com/91

 

이클립스 CDT로 C/C++ 개발 시작하기

목차 들어가기 이클립스 CDT 설치하기 이클립스로 C/C++ 프로그램 개발하기 마무리 들어가기 이전 포스팅에서 이클립스에 대한 소개를 해봤다. 이제 본격적으로 CDT를 이용한 개발에 대해서 이야기해보려고 한다...

kkangeva.tistory.com

 

방법.

1. C/C++ 개발자용 이클립스 다운로드

2. 이클립스 설치 후 CDT 플러그인 추가 (선택)

 

[Eclipse에 CDT 플러그인을 추가하는 방법]

#1. Eclipse 메뉴 help > Install New Software 선택

#2. Work with에 https://www.eclipse.org/cdt/downloads.php 에서 알맞는 버전의 p2 software repository 주소 복사 후 붙여넣기

(cf. Eclipse 2018-12 버전이라 "http://download.eclipse.org/tools/cdt/releases/9.6" 복붙)

#3. Select All 후 설치

 

[Eclipse에서 C++ 프로그램을 개발하는 방법]

#1. 인코딩 세팅

- Eclipse 메뉴에서 Preferences 에서 General > Workspace 에서 Text file encoding 항목에 Other: UTF-8 체크

#2. Project 생성

- 네비 Context menu에서 new > Other > C/C++ Project > C++ Managed Build > Project Type : Empty Project & Toolchains : MinGW GCC > Finish!

#3. Source File 생성

- 프로젝트의 Context menu에서 new > Source File > Finish!

#4. 코드 작성 후 실행

- 실행 순서 : 저장(Ctrl + S) > Build > Run(Ctrl + F11)

 

 

'프로그램 설치' 카테고리의 다른 글

Visual Studio Code에서 C/C++ 컴파일 사용법  (0) 2019.06.17
블로그 이미지

uchacha

개발자 일지

,

방법1.

@ 참고 : https://webnautes.tistory.com/1158

▶ #1, #2, #5는 참고2 활용

#1. C/C++ 컴파일러(MinGW) 설치
#2. 'Code Runner' 확장 기능 설치
#3. 메뉴 > 터미널 > 기본 빌드 작업 구성 -> 탐색기에 tasks.json파일이 추가됨
#4. tasks.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
                }
            }
        },
        // 바이너리 실행(Ubuntu)
        // {
        //     "label": "execute",
        //     "command": "cd ${fileDirname} && ./${fileBasenameNoExtension}",
        //     "group": "test"
        // }
        // 바이너리 실행(Windows)
        {
            "label": "execute",
            "command": "cmd",
            "group": "test",
            "args": [
                "/C", "${fileDirname}\\${fileBasenameNoExtension}"
            ]
    
        }
    ]
}

** 이때 단축키 설정해서 사용하면 window has crashed 에러 메세지 뜨므로 단축키 없이 실행!!

#5. 파일 실행(단축키: Ctrl + Alt + N)


방법2. 실행했을 때 output의 encoding이 깨짐

@ 참고 : https://taking.kr/blog/archives/4825.html

#1. MinGW 다운로드

1. https://sourceforge.net/projects/mingw/files/latest/download 다운로드를 통해 설치를 진행한다.
2. 설치 후, MinGW Installation Manager에 다음 패키지를 선택 후, Apply Changes를 눌러 설치한다.

- mingw-developer-toolkit

- mingw32-base

- mingw32-gcc-g++

-msys-base

3. 컴퓨터 -> 속성 -> 고급 시스템 설정 -> 시스템 속성[고급 탭] -> 환경 변수 -> Path 변수에
C:\MinGW\bin을 추가한다.
4. 정상적으로 gcc / g++ 컴파일러가 설치되었는지 확인하기 위해 명령 프롬프트(cmd)를 켜 확인해본다.

- gcc --version

- g++ --version

#2. VS Code 컴파일 환경설정

1. 확장 마켓플레이스에서 'Code Runner'를 설치한다.
- 지원 언어 : C, C++, Java, Python, Visual Basic .Net, Kotlin 등
2. 설정(ctrl+,) -> {} settings.json 안에 다음 설정 추가

   // Code Runner "CPP" 설정

    "code-runner.executorMap": {

    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"

    },

    // Window 10 에서는 Default Shell 이 Powershell이기 때문에 cmd로 변경해야 정상적으로 실행 됨.

    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"

3. 파일 생성 후 실행(단축키: Ctrl+Alt+N)

- helloworld.c

#include <stdio.h>

int main() {
    printf("안녕\n");
    return 0;
}

- helloworld.cpp

#include <iostream>
using namespace std;

int main() {
    cout << "안녕" << endl;
    return 0;
}

'프로그램 설치' 카테고리의 다른 글

이클립스 CDT로 C/C++ 개발 시작하기  (0) 2019.09.05
블로그 이미지

uchacha

개발자 일지

,