Created
August 22, 2014 05:40
-
-
Save zodiac1111/a791c063e8e43a45fadd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "staticlib.h" | |
int main(void) | |
{ | |
printf("静态库链接示例: %d\n",foo(41)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY:all staticlib main clean | |
all: staticlib main | |
staticlib: | |
gcc -c staticlib.c -o staticlib.o | |
ar -r staticlib.a staticlib.o | |
main: | |
gcc main.c staticlib.a | |
clean: | |
rm -f *.a *.o a.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "staticlib.h" | |
int foo(int a) | |
{ | |
return ++a; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//filename: staticlib.h | |
//最简单的库函数演示头文件. | |
#ifndef STATICLIB_H | |
#define STATICLIB_H | |
int foo(int a); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment