일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- console창
- Visual Studio Code
- 파이썬
- OrCAD 다운로드
- import data
- cmd
- run sql script
- php
- csv
- github token
- 클론
- github clone
- error 해결
- error
- database
- 데이터베이스
- 에러
- jupyter
- visualstudio code
- PHPStorm
- 오류
- 깃 토큰
- DataGrip
- clone
- localhost
- 단축키
- MySQL
- Python
- 따옴표 삭제
- vscode
Archives
- Today
- Total
개발 노트
9/22 p.81 gcc, makefile 파일 본문
<p.81 : gcc>
$vi sum.c로 내용 작성
int sum(int a, int b) {
return a + b;
}
$vi helloworld.c로 내용 작성
#include <stdio.h>
int sum(int, int);
int main(int argc, char **argv)
{
printf("Hello World\n");
printf("Sum : %d\n", sum(3,5));
return 0;
}
$gcc -o helloworld hellworld.c sum.c 작성 후
$./helloworld 하면
결과 출력됨
Hello World
Sum : 8
<p.84 : makefile 파일>
$vi makefile
all : //all : 쓰고 enter쳐서 밑의 줄의 tab 처리 된 다음부터 작성하도록 해야 함
gcc -o helloworld helloworld.c sum.c
//위와같이 makefile을 만들어두면 make만 실행해도 하단처럼 안의 명령문 실행됨
$ make
gcc -o helloworld helloworld.c sum.c
$ ./helloworld
Hello World
Sum : 8
$ vi makefile2
all : helloworld.o sum.o
gcc -o helloworld helloworld.o sum.o
helloworld.o : helloworld.c
gcc -c helloworld.c
sum.o : sum.c
gcc -c sum.c
$ make -f makefile2 //실행하면 하단 내용 출력됨
gcc -c helloworld.c
gcc -c sum.c
gcc -o helloworld helloworld.o sum.o
$ ./helloworld
Hello World
Sum : 8
참고로 -c 는 컴파일만 하라는 뜻
반응형
'학부 공부 : 20.08.31~12.10 > Linux' 카테고리의 다른 글
10/13 동시에 2개 파일로 복사하는 코드, 앞 내용 절반 뒷 내용 절반씩 나누어 복사하는 코드 (0) | 2020.10.14 |
---|---|
9/16 p.67 Linux 에서 tar로 파일 묶기, 파일 확인, 파일 묶음 풀기 실습 (0) | 2020.09.19 |
9/8 p.53 리눅스의 계층적 구조 (0) | 2020.09.08 |
9/1 p.55 sudo로 권한 다루기 (0) | 2020.09.01 |