개발환경구축 부산대학교정보컴퓨터공학부 김종덕 (kimjd@pusan.ac.kr)
강의의목표 Compiled Language vs. Interpreted Language 차이이해 Compiling의의미이해 Compiling의결과물확인 통합개발환경구축 Eclipse 통합개발환경을통한예제의 Bulid 및실행 Formatter 등의편집지원기능, Reference의준비 Warning 및 Error 메시지, 디버깅모드 2
C 코드및컴파일맛보기 (1) 1. Explorer 를실행시키고프로그래밍을할작업폴더를준비하라. 1 Ex) F:\Workspace 2. cmd( 명령프롬프트 ) 를실행시키고작업폴더로이동하라. 1 2 Explorer 에서작업폴더를선택하고 Shift + 마우스오른키 를누르면 여기서명령창열기 활성화됨. 선택 또는 cmd 실행후 cd 등의명령으로이동 3. gcc ( 컴파일러 ) 를실행해보라. 1. 아래그림과같이실행결과는에러이지만실행이됨을확인하라. 2. where gcc 로컴파일러설치위치를확인하라. 3
C 코드및컴파일맛보기 (2) 4. Cmd 에서 notepad hello.c 를입력하여 hello.c 라는 C 코드파일을 작업폴더에생성하라. 5. Hello.c 를다음과같이작성하고저장하라. 1 화면에 Hello World!!! 라는문자열을출력하는프로그램 4
C 코드및컴파일맛보기 (3) 7. dir 을통해작업폴더내에존재 하는파일을확인하라. 1 새로만든작업폴더라면 Hello.c 라는 소스코드파일만존재할것이다. 8. gcc hello.c 를입력하여컴파일 을수행하라. 9. dir 을통해컴파일후작업폴더 내에존재하는파일을확인하라. 1 a.exe 라는실행파일이생성되었음 을확인할수있을것이다. 10. a.exe 를실행해보라. 5
Python 과 Interpretation 1. python 을실행하고 Hello World!!! 출력코드를작성해보라. 1 2 Python shell이실행되면서코드를입력할수있는 Prompt가생김을확인할수있다 Print 명령문을활용하여 Hello World!!! 를출력해보라 3 exit() 로 Python Shell 을종료시켜라. 2. Notepad hello.py 를실행시키고위와동일한코드를작성해보라. 3. python hello.py 를통해실행결과를확인하라. 실행파일이생성되는가? 6
Compiler vs. Interpreter 비교항목 Compiler Interpreter 실행 / 목적파일생성생성안함 실행속도빠름느림 이식성 (Portability) 낮음. ISA 가다른컴퓨터에서는다시컴파일해야함 높음인터프리터만있으면 ISA 가다른컴퓨터에서도실행가능 대표언어 C/C++, Fortran, Cobol Python, Java, Basic 실행 / 목적파일의생성여부가중요한차이 컴퓨터가이해할수있는언어는 Machine Code라불리는, 각 CPU의 ISA(Instruction Set Architecture) 에따른이진 (Binary) 코드임 ; CPU 마다 ISA가다름 실행 / 목적파일은이러한이진코드로만들어짐 Interpreter의경우전체코드를대상으로하는 Compile 단계없이한번에하나의문장을번역 ( 해석 ) 하며실행함 Interpreted Language의경우 Interpreter가없으면실행할수없음 Compiled Language 의경우실행 / 목적파일이있으면소스코드와 Compiler 가없어도실행가능 소스코드 C 언어의세부 Compile 과정은이후강의에서추가설명 소스코드 Compiler 입력 Interpreter 출력 입력 실행 / 목적파일 출력 7
프로그래밍언어의분류와 Compiling C/C++, Python Compiling Computer (Von Neumann Model) 8
소프트웨어개발및프로그래밍과정 소프트웨어개발과정 "Software Engineering 교과에서심도있게다룰것임 요구사항분석 (requirement analysis) 사용자의요구사항즉소프트웨어가해야할일을파악하는단계사용자는요구사항을명세서 (specification) 형태로제시한다. 설계 (design) 요구사항을구체화하는단계로소프트웨어의구조를결정파악된문제를해결하는알고리즘 (algorithm) 을흐름도 (flow chart) 나의사코드 (pseudo code) 형태로표현 구현 (implementation) 설계된내용을구체적인프로그래밍언어로작성하는단계프로그램을작성하는것을코딩 (coding) 한다고한다. 테스트 (testing) 프로그램의오류를찾아내고이를수정하는단계프로그램오류는컴파일시간오류, 실행시간오류, 논리오류등이있음 유지보수 (maintenance) 개발된소프트웨어를실제상황에서운영하면서상황및변화된요구에따라소프트웨어를적절하게수정하는단계 구문오류 (Syntax Error) : 프로그램의문법오류 논리오류 (Logical Error) : 프로그램의논리적기능오류 실행오류 (Run-time Error) : 프로그램이비정상적으로멈추거나종료되는치명적오류 프로그래밍은소스코드를작성하는과정만을의미하는것이아님!!! 9
개발도구 / 환경의중요성 Editor, Compiler, Debugger 등의개발도구 여러개발도구들을통합하여프로그램을개발하는전과정에서편리하고생산적으로작업할수있도록돕는통합도구또는환경 프로그램 IDE : Integrated Development Environment 10
IDE 의선택 C Programming 을위한개발환경은? 무료, Windows/Linux/iOS 등멀티플랫폼지원 Java, C/C++, Python, Android 등지원 Eclipse is an open-source Integrated Development Environment (IDE) supported by IBM. The mother site is @ www.eclipse.org. Eclipse is popular for Java project development. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and Mac OS 1-1 1-2 2-1 2-2 컴퓨터시스템입문 (Introduction to Computer System) C 프로그래밍 (C Programming) 객체지향프로그래밍 (Object Oriented Programming) 플랫폼기반프로그래밍 (Platform based Programming) Java Python C C++ 자료구조 (Data Structures) 웹응용프로그래밍 (Web Application Programming) C++ HTML, PHP, JavaScript 11
Eclipse 설치 Eclipse Installer 활용 유의점1: Eclipse는특정언어나환경에특화된여러 Package가있다. 단 Plug-In을통해확장이가능, 예를들어 Java Developer 용 IDE를설치한후 CDT Plug-In을추가하여 C/C++ 개발기능추가가가능함 유의점 2: Compiler 등 Platform 에종속적인도구는 별도로설치하여야한다. (Toolchain) Windows 환경에서 Eclipse 와연계하여사용하는 대표적 Toolchain 으로는 MinGW, CygWin 등이있음 유의점 3: Eclipse 는 Java 로작성된프로그램으로 실행을위해서는 Java 가설치되어있어야한다. Java Virtual Machine 이필요 유의점 4: 32/64Bit Version 이슈 혼동을줄이기위해 32bit version 설치권장 한글로작성된설치도움말 12
MinGW : Minimalist GNU for Windows 설치 Install 프로그램실행후설치폴더지정 C/C++ 개발관련패키지선택 설치개시 13
PATH 변수변경 Eclipse 에서 MinGW Toolchain 의존재를인식하기위해서는 MinGW 설치폴더가 PATH 변수에포함되어야함 설치폴더에내용을확인하시오. Bin 폴더 : Binary 실행파일들이설치되는폴더 Include, lib : C 프로그래밍에필요한헤더파일과라이브러리파일 MinGW\msys\msys.bat 실행해보시오 Bourne Shell MinGW forked from version 1.3.3 of Cygwin. Although both Cygwin and MinGW can be used to port UNIX software to Windows, they have different approaches: Cygwin aims to provide a complete POSIX layer that provides emulations of several system calls and libraries that exist on Linux, UNIX, and the BSD variants. The POSIX layer runs on top of Windows, sacrificing performance where necessary for compatibility. Accordingly, this approach requires Windows programs written with Cygwin to run on top of a copylefted compatibility library that must be distributed with the program, along with the program's source code. MinGW aims to provide native functionality and performance via direct Windows API calls. Unlike Cygwin, MinGW does not require a compatibility layer DLL and thus programs do not need to be distributed with source code. 14
Eclipse CDT 설치 설치폴더내용확인해볼것 전산실 PC 를활용할경우등을고려해휴대저자장치 (USB 디스크 ) 에작업폴더를만드는방안고려할것 15
Eclipse 실행및기본동작확인 프로젝트명중복되지않게입력 새로운 C 프로젝트생성 MinGW GCC Toolchain 확인 프로젝트에새로운소스파일추가추가소스파일명에.c 확장자.c 에서 c 는반드시소문자 16
코드편집및저장 / 프로젝트폴더내용확인 줄번호옆벌레아이콘, 붉은밑줄이의미하는것은? 프로젝트파일과소스파일만존재 17
Build / 프로젝트폴더내용확인 / Run Debug Version : 실행파일에디버깅정보포함 파일크기큼, Optimization 적용최소화 Release Version : 디버깅정보제외 Run ( 실행 ) Debug 폴더가만들어지고그속에 CProject1.exe 와 Hello.o 생성 실행결과 Console 출력 Build 과정의메시지 18
Debug? Step Into (F5) : Click 또는 F5 를눌러소스코드창과 Variables 의변화를확인하라 Call Stack Variables Tab 프로그램의변수값확인가능 Disassembly 디버그종료 (Ctrl-F2) Debug Perspective/View 에서 C/C++ Programming Perspective/View 로전환 19
참고 :Eclipse Java 설치후 CDT 추가방법 20