Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1063172
  • 博文数量: 284
  • 博客积分: 8223
  • 博客等级: 中将
  • 技术积分: 3188
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-01 13:26
文章分类

全部博文(284)

文章存档

2012年(18)

2011年(33)

2010年(83)

2009年(147)

2008年(3)

分类: C/C++

2009-08-07 11:24:42

makefile :
 

LIB = ./libfun.so

all : clean libfun.so sem end

.PHONY : all

clean :

   -rm ./exe/*.o ./exe/core ./exe/libfun.so sem

libfun.so : libfun.o

   cc -G -o libfun.so libfun.o

libfun.o : libfun.c

   cc -g -KPIC -c libfun.c

sem : sem.o

   cc -g -o sem sem.o $(LIB)

sem.o : sem.c

   cc -g -c sem.c $(LIB)

end :

   -mkdir exe

   -mv *.o core *.so sem ./exe/

 

sem.c:

#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

extern void pp();
void main(int argc,char **argv[])
{
   pp();
}

libfun.c :

#include <stdlib.h>
#include <stdio.h>
void pp();

void pp()
{
   printf("i am toy\n");
}

这里与静态库相比,只有makefile部分进行了修改。

 

阅读(1439) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~