Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- test
- C
- eSIM
- Android
- 다윈
- ethereum
- 컴파일
- 사용자중심기획
- 데이터해석능력
- 앱기획자
- Glide
- 글라이드로앱만들기
- Realm
- 스트리밍
- log
- 기획자
- error
- kotlin
- 앱기능설명
- 데이터분석
- Gradle
- firebase
- Exception
- 데이터활용능력
- 노코드활용
- 해외여행데이터
- 웹기획자
- convert
- 기획자역량
- 안드로이드
Archives
- Today
- Total
날마다 새롭게 또 날마다 새롭게
정적 라이브러리 만들기 - 예제 본문
1. 라이브러리로 만들 헤더파일과 소스파일을 만든다.
power.h
int power(int m, int n);
power.c
#include "power.h"
int power(int base, int n)
{
int i,p;
p=1;
for(i=1;i<=n;++i)
p=p*base;
return p;
}
2. 오브젝트를 만든다.
gcc -c power.c
3. 라이브러리 아카이브를 만든다.
ar rc libpower.a power.o
4. 라이브러리를 사용한 테스트 코드를 만들고 컴파일 시에 라이브러리 위치와 이름을 명시해준다.
gcc -o test test.c -L./ -lpower
-L은 라이브러리 위치를 -l은 라이브러리 이름을 나타낸다.
테스트 코드
#include "stdio.h"
#include "power.h"
/* test power function */
int main()
{
int i;
for(i=0;i<10;i++)
printf("%d %d %d\n",i,power(2,i),power(-3,i));
return 0;
}
출처 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/C/Documents/Make_Library
Comments