Header Files and Libraries in MikroC PRO

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Header files and Libraries in mikroC PRO

Header file is file that becomes the part of you program without writing new code just we have to say include as: # include <lcd.h> and it become the part of your program and saves time, for example most of time we have to use LCD in out project so we have to define LCD connections as:
// Lcd pinout settings sbit LCD_RS at Rd2_bit; sbit LCD_EN at Rd3_bit; sbit LCD_D7 at Rd7_bit; sbit LCD_D6 at Rd6_bit; sbit LCD_D5 at Rd5_bit; sbit LCD_D4 at Rd4_bit; // Pin direction sbit LCD_RS_Direction at TRISd2_bit; sbit LCD_EN_Direction at TRISd3_bit; sbit LCD_D7_Direction at TRISd7_bit; sbit LCD_D6_Direction at TRISd6_bit; sbit LCD_D5_Direction at TRISd5_bit; sbit LCD_D4_Direction at TRISd4_bit;

Moreover, every time writing this code is laborious so I try to make its header file so that next time I just have to say: # include <lcd.h> and this code become the part of my new program code.

Making Header File


Open the mikroC, close all open files in IDE then make a new file (not new project, close all projects) write the code, which you want to make the part of other projects code.

Save option will automatically appear after some time, Save As this file as header file .h and it has done. Open any other file and #include <lcd.h> and enjoy your own header file.

Libraries
Libraries are files that do not have to #include in program code but they become the part of you program if you check that library in Library Manager of mikroC PRO for PIC as shown in the figure.

Making libraries
New file must be added to the project source file from project manager and then compile the project to make this file as library file. You must have to change some settings in output setting form Tools Options Output Settings. Build all files as library. Always build all files in project. After compiling a .mcl will be created in the folder where you Save As your New file this is library file of your New file. Use package manager from MikroElektronika (free tool) to make package of this file, and then install this to include this library in required place.

You might also like