Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to Create Static lib
AddTwoNumber (long first, long second){
return first + second;
#include <stdio.h>
long SubTwoNumber (long, long);
long AddTwoNumber (long, long);
main (void){
printf ("[2-3]=[%ld]\n", SubTwoNumber (2, 3));
printf ("[2+3]=[%ld]\n", AddTwoNumber (2, 3));
return 0;
output: libmat.a
cc main.c -o output -L. -lmat
libmat.a: add.o sub.o
ar rcs libmat.a add.o sub.o
%.o: %.c
cc -c $<
.[PHONY]: clean
yes | rm *.o
yes | rm output
yes | rm lib*.a
SubTwoNumber (long first, long second){
return first - second;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.