大龙的博客

常用链接

统计

最新评论

Linux如何生成.a文件

.a文件是静态库文件,他是很多个.o文件的集合。
例如:cnapsapi.a: $(APPOBJ)/cnapsapi.o $(APPOBJ)/queue.o
         ar -rcs $(APPOBJ)/cnapsapi.a $(APPOBJ)/cnapsapi.o $(APPOBJ)/queue.o

意思就是说把cnapsapi.o,queue.o两个文件生成一个cnapsapi.a静态库文件。

多谢,那我要是在编译另一个.c文件的时候需要使用这个.a文件,gcc里应该加什么参数阿
加入-l 参数啊,
     Linking is always the last stage unless you use one of the
        -c,   -S,   or -E options to avoid it (or unless compilation
        errors stop the whole process).   For the link   stage,   all
        .o   files   corresponding   to   source   files, -l libraries,
        unrecognized filenames (including named   .o   object   files
        and   .a archives) are passed to the linker in command-line

posted on 2009-05-26 10:03 大龙 阅读(1586) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理