.a文件是静态库文件,他是很多个.o文件的集合。
例如:cnapsapi.a: $(APPOBJ)/cnapsapi.o $(APPOBJ)/queue.o
ar -r $(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
order.
(iwgh)