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

15번째 줄: 15번째 줄:
[[File:files.png|600px]]
[[File:files.png|600px]]


===파일 내용===
===파일 코드 내용===
{{소스헤더|a.c}}
{{소스헤더|a.c}}
<source lang='C'>
<source lang='C'>
56번째 줄: 56번째 줄:
     return 0;
     return 0;
}
}
</source>
===컴파일 하기===
*object 파일 생성
<source lang='console'>
$ gcc -c -o a.o a.c
$ gcc -c -o b.o b.c
$ gcc -c -o main.o main.c
</source>
*실행 파일 생성
<source lang='C'>
gcc -o exefile main.o a.o b.o
</source>
* 실행파일 실행해보기
<source lang='C'>
$ ./exefile
foo
bar
</source>
</source>



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

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
  • 실행 파일 생성
gcc -o exefile main.o a.o b.o
  • 실행파일 실행해보기
$ ./exefile
foo
bar

작성중...

5 같이 보기

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