@snuffles
2015-03-16T05:55:48.000000Z
字数 421
阅读 949
linux
首先是需要编译成.a的源文件
hello.h
#ifndef __INCLUDE_HELLO_H__
#define __INCLUDE_HELLO_H__
void hello(const charchar *name);
#endif // end __INCLUDE_HELLO_H__
hello.c
#include "stdio.h"
void hello(const charchar *name)
{
printf("Hello world %s\n", name);
}
和一个在linux平台上做测试的main.c
#include "hello.h"
int main()
{
hello("everyone");
return 0;
}
编译出.a的指令
gcc -c hello.c
ar cr libhello.a hello.o
gcc main.c -L -lhello -o main