"Makefile 만들기"의 두 판 사이의 차이

12번째 줄: 12번째 줄:
==컴파일 예제==
==컴파일 예제==
===파일 개요===
===파일 개요===
*a.c (a.h), b.c (b.h), main.c 파일을 각각 만들어 보자
a.c (a.h), b.c (b.h), main.c 파일 생성
 
[[File:files.png|600px]]
[[File:files.png|600px]]



2018년 6월 13일 (수) 20:14 판

1 개요

makefile 만들기
How to make the makefile
  • make 빌드를 위한 makefile 만들기

2 make 란?

3 makefile 이란?

4 컴파일 예제

4.1 파일 개요

a.c (a.h), b.c (b.h), main.c 파일 생성

Files.png

4.2 파일 코드 내용

a.c
#include <stdio.h>

void foo()
{
    printf("foo\n");
}
a.h
void foo();
b.c
#include <stdio.h>

void bar()
{
    printf("bar\n");
}
b.h
void bar();
main.c
#include "a.h"
#include "b.h"

int main()
{
    foo();
    bar();

    return 0;
}

4.3 컴파일 하기

object 파일 생성
$ gcc -c -o a.o a.c
$ gcc -c -o b.o b.c
$ gcc -c -o main.o main.c
→ -c 는 컴파일, 어셈블 수행
→ -o 는 파일명을 정함
실행 파일 생성
gcc -o exefile main.o a.o b.o
→ 링킹하여 실행파일 생성
실행파일 실행해보기
$ ./exefile
foo
bar

작성중...

5 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}