1. 程式人生 > >keil c中檔案打包成lib檔案

keil c中檔案打包成lib檔案

1.選擇:projects   -   options   for   target   'target   1'   , 在   output   頁選中   create   library ,  使將要打包的檔案生成LIB和OBJ檔案.

如將如下檔案:

/***************************************************/
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
/************************************************/
void Delay(unsigned int m)
{
 unsigned int n;
 n=0;
 while(n < m)
 {n++;}
 return;
}

建立工程後,生成OBJ,LIB檔案. 

2.在keil c  下的INC檔案裡面放入如下標頭檔案(DELAY.H):


#ifndef __DELAY_H__
#define __DELAY_H__

#pragma SAVE
#pragma REGPARMS

extern void Delay(unsigned int m);

#pragma RESTORE

#endif

3.在新建的工程(其它檔案)中,將生成的LIB檔案加入,並在MAIN檔案裡把DELAY.H #include進去,如圖: