UNIX下C语言编程动态库的生成

1.设计库代码

pr1.c

1 int p = 2;
2 void print()
3 {
4     printf("This is the first dll src !\n");
5 }
View Code

pr2.c

1 int p = 3;
2 void print()
3 {
4     printf("This is the second dll src !\n");
5 }
View Code

2.编绎

1 gcc -fpic -c pr1.c pr2.c
2 gcc -shared -o pr1.so pr1.o
3 gcc -shared -o pri2.so pr2.o
View Code

 

posted @ 2014-09-22 18:26  天天AC  阅读(162)  评论(0编辑  收藏  举报