shared library 사용하기
1. library source 파일 작성
/* shlibtest.c */ #include <stdio.h> int aa() { printf("aa\n"); } int bb() { printf("bb\n"); }
2. shared library 빌드
gcc -shared -fPIC -o shlibtest.so shlibtest.c
3. shared library 내의 함수를 이용할 test source 작성
/* test.c */ int main() { aa(); bb(); }
4. test source 컴파일
gcc -o test test.c -L. -lshlibtest
5. 실행