Linux 下用gcc生成静态库和动态库
一、用 gcc 生成 .a 静态库和 .so 动态库
1.创建一个 test1 文件夹
#mkdir test //创建test文件夹
#cd test1 //进入该文件夹
在该文件夹中创建三个子程序 hello.h、hello.c 和 main.c下面展示一些 内联代码片
vim hello.h // 编辑hello.h
vim hello.c // 编辑hello.c
vim main.c // 编辑main.c
程序 1: hello.h
#ifndef HELLO_H
#define HELLO_H
void hello(const char *name);
#endif //HELLO_H
程序 2: hello.c
#include <stdio.h>
void hello(const char *name)
{
printf("Hello %s!\n", name);
}
程序 3: main.c
#include "hello.h"
int main()