目录
1.创建文件test并使用文本编辑器Vim编程程序hello.h,hello.c和main.c。
一.gcc生成静态库和动态库
1.创建文件test并使用文本编辑器Vim编程程序hello.h,hello.c和main.c。
mkdir test//创建文件夹test
cd test//打开文件夹tes
按Esc键进入命令模式,输入:wq 然后敲击enter保存退出
以此类推
main.c
#include "hello.h"
int main() {
hello("everyone");
return 0; }
hello.c
#include <stdio.h>
void hello(const char *name)
{printf("Hello %s!\n", name); }
hello.h
#ifndef HELLO_H
#define HELLO_H
void hello(const char *name);
#endif //HELLO_H
2.将hello.c编译成.o文件。
3.由.o文件创建静态库。