make library with the new compiler..!!

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
trasalb
Posts: 58
Joined: 23 Mar 2009 19:24

make library with the new compiler..!!

#1 Post by trasalb » 26 Mar 2009 16:13

these were the step for creating a library whit the old micro C version:

1) Create new C file (mikroC->File->New)
2) Save the file in one of the following folders:
C:ProgrammiMikroelektronikamikroCUsesP16
C:ProgrammiMikroelektronikamikroCUsesP18
If you are creating library for PIC16 MCU family the file should be saved in P16 folder.
If you are creating library for PIC18 MCU family the file should be saved in P18 folder.
If you are creating library for PIC16 and PIC18 MCU families the file should be saved in both folders.
3) Write the code for your library and save it.
4) Open the "mlk" file for the MCU that you want to use. The "mlk" file is placed in the following folder:

C:ProgramiMikroelektronikamikroCdefs

Add the following line in the definition file for the MCU:
#pragma SetLib(Your_Lib_ Name)
note: this step should be repeated for each MCU that you intend to use
5) Restart the compiler.

---
Best regards,

Goran Pavlovic
mikroElektronika Support Team
http://www.mikroe.com/

These steps with new version still work?.
Is there an other solution?.You can gives me an example.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

#2 Post by filip » 27 Mar 2009 09:30

Hi trasalb,

Adding/creating new library in mikroC PRO for PIC is done in this way:
  1. Create a new C source file, for example __Lib_Example.c.
  2. Save the file in one of the subfolders of the compiler's Uses folder:
    DriveName:\Program Files\Mikroelektronika\mikroC PRO for PIC\Uses\P16\
    DriveName:\Program Files\Mikroelektronika\mikroC PRO for PIC\Uses\P18\

    If you are creating library for PIC16 MCU family the file should be saved in P16 folder.
    If you are creating library for PIC18 MCU family the file should be saved in P18 folder.
    If you are creating library for PIC16 and PIC18 MCU families the file should be saved in both folders.
  3. Write a code for your library and save it.
  4. Add __Lib_Example file in some project, see Project Manager. Recompile the project.
  5. If you wish to use this library for all MCUs, then you should go to Tools > Options > Output settings,
    and check Build all files as library box. This will build libraries in a common form which will work with all MCUs.
    If this box is not checked, then library will be built for selected MCU.
    Bear in mind that compiler will report an error if a library built for specific MCU is used for another one.
    Compiled file __Lib_Example.mcl should appear in ...\mikroC PRO for PIC\Uses folder.
  6. Open the definition file for the MCU that you want to use. This file is placed in the compiler's Defs folder:
    DriveName:\Program Files\Mikroelektronika\mikroC PRO for PIC\Defs, and it is named MCU_NAME.mlk, for example P16F887.mlk.
    Add the the following segment of code to <LIBRARIES> node of the definition file (definition file is in XML format):

    Code: Select all

        <LIB>                                                                                                                   
          <ALIAS>Example_Library</ALIAS>                                                                                        
          <FILE>__Lib_Example</FILE>                                                                                            
          <TYPE>REGULAR</TYPE>                                                                                                  
        </LIB>
  7. Add Library to mlk file for each MCU that you want to use with your library.
  8. Click Refresh button in Library Manager
  9. Example_Library should appear in the Library manager window.
Regards,
Filip.

trasalb
Posts: 58
Joined: 23 Mar 2009 19:24

make library now it's possible..!

#3 Post by trasalb » 27 Mar 2009 13:49

thank you so much of your help,now everything is OK....!!!!

matrix
Posts: 203
Joined: 26 Jan 2006 07:21
Location: Bulgaria
Contact:

#4 Post by matrix » 28 Mar 2009 09:41

Can we use library compiled in mikroC with microPascal?

Post Reply

Return to “mikroC PRO for PIC General”