博客
关于我
Keil 下生成LIB库文件以及如何使用LIB库文件
阅读量:152 次
发布时间:2019-02-27

本文共 2026 字,大约阅读时间需要 6 分钟。

Keil 下生成LIB库文件以及如何使用LIB库文件

如何生成LIB库文件?

1.   首先准备好生成LIB库文件对应的.c和.h文件,我这里用到的.c和.h文件分别是:

commLib.h:

 

/*======================================================*//* 延时函数,单位ms										*//* 晶振频率为11.0592MHz时延时1ms子程序 					*//*======================================================*/void delay(int ms);/*======================================================*//* 循环左移函数	2015年7月27日 21:34:44			 		*//*======================================================*/unsigned char ccCrol(unsigned char org, unsigned char bitNum);/*======================================================*//* 循环右移函数	2015年7月29日 21:40:39		 			*//*======================================================*/unsigned char ccCror(unsigned char org, unsigned char bitNum);

 

commLib.c:

 

/*======================================================*//* 延时函数,单位ms										*//* 晶振频率为11.0592MHz时延时1ms子程序 					*//*======================================================*/void delay(int ms){	int i, j;	for (i = ms; i > 0; i--)	{		for (j = 110; j > 0; j--)		{		}	}}/*======================================================*//* 循环左移函数	2015年7月27日 21:34:44		 			*//*======================================================*/unsigned char ccCrol(unsigned char org, unsigned char bitNum){	unsigned char i;	unsigned char high, low;	unsigned char after = org;		for (i = 0; i < bitNum; i++)	{		high = after & 0x80;		low = high >> 0x07;		after <<= 0x01;		after |= low;	}		return after;}/*======================================================*//* 循环右移函数	2015年7月29日 21:40:39		 			*//*======================================================*/unsigned char ccCror(unsigned char org, unsigned char bitNum){	unsigned char i;	unsigned char high, low;	unsigned char after = org;		for (i = 0; i < bitNum; i++)	{		low = after & 0x01;		high = low << 0x07;		after >>= 0x01;		after |= high;	}		return after;}

 

 

2.        新建一个项目,将这两个文件添加到袄项目中,并做以下设置:

选中Create Library

 

 

 

3.        编译之后就可在项目目录下生成对应的.LIB库文件了。

 

 

 

如何使用LIB库文件呢?

1.        新建一个项目,然后在你的项目中包含LIB库文件对应的头文件commLib.h。

如图:

 

2.        添加LIB库文件到项目中:

 

然后选择你要添加的LIB库文件:

 

 

添加完成之后就可以在项目中看到对应的库文件了:

 

3.        编译项目就OK了。

你可能感兴趣的文章
MySQL 到底能不能放到 Docker 里跑?
查看>>
mysql 前缀索引 命令_11 | Mysql怎么给字符串字段加索引?
查看>>
MySQL 加锁处理分析
查看>>
mysql 协议的退出命令包及解析
查看>>
mysql 参数 innodb_flush_log_at_trx_commit
查看>>
mysql 取表中分组之后最新一条数据 分组最新数据 分组取最新数据 分组数据 获取每个分类的最新数据
查看>>
MySQL 命令和内置函数
查看>>
mysql 四种存储引擎
查看>>
MySQL 在并发场景下的问题及解决思路
查看>>
MySQL 基础架构
查看>>
MySQL 基础模块的面试题总结
查看>>
MySQL 备份 Xtrabackup
查看>>
mYSQL 外键约束
查看>>
mysql 多个表关联查询查询时间长的问题
查看>>
mySQL 多个表求多个count
查看>>
mysql 多字段删除重复数据,保留最小id数据
查看>>
MySQL 多表联合查询:UNION 和 JOIN 分析
查看>>
MySQL 大数据量快速插入方法和语句优化
查看>>
mysql 如何给SQL添加索引
查看>>
mysql 字段区分大小写
查看>>