Ok, I give up -- how do I make and use my own library. Is there a guide for doing this? I couldn't find anything much in the manual or compiler help.
I have a pretty good task dispatcher written. I used to just copy the source file into any project that needed the dispatcher, but lately decided to get more sophisticated and make a library out of it. There seems to be a demand for multi-tasking systems, and even though this is a long way from a full RTOS I find it very useful. I am sure others will too, so I may release it for free use once I get this library stuff sorted out.
I can compile it (V6.2 compiler) seperate from any project, but only if I have a main(), which may or may not be an issue.
Anyway, when I add the .mcl file to another project the compiler doesn't know about the functions within the library. Do they have to be declared as public or something? I'd like to hide the internal procedures too (private?). I tried using those keywords without success.
-- Pete
Make and use my own library
Re: Make and use my own library
PeteNZ wrote:Ok, I give up -- how do I make and use my own library. Is there a guide for doing this? I couldn't find anything much in the manual or compiler help.
I have a pretty good task dispatcher written. I used to just copy the source file into any project that needed the dispatcher, but lately decided to get more sophisticated and make a library out of it. There seems to be a demand for multi-tasking systems, and even though this is a long way from a full RTOS I find it very useful. I am sure others will too, so I may release it for free use once I get this library stuff sorted out.
I can compile it (V6.2 compiler) seperate from any project, but only if I have a main(), which may or may not be an issue.
Anyway, when I add the .mcl file to another project the compiler doesn't know about the functions within the library. Do they have to be declared as public or something? I'd like to hide the internal procedures too (private?). I tried using those keywords without success.
-- Pete
Creating library files and their use:
1. make c file that contains all your library functions,
it must not contain definition of main,
also take care that name of your library file is unique
and will not conflict with default libraries that are located
in corresponding uses folder
2. add your c file to any project and build project
you will get mcl file.
Now we have our library but how to use it.
There are 2 ways to achive this:
1. add mcl file to any project as library file.
in order to make any other file in project
see declaration of function in this file
you must
-make header file *.h with all protypes of
functions that are pubilc and should be visible
-include this header file where you need this
library functions.
2. you may consider to make this library loaded by default
then you do not have to make header file
and will see all functions on CTRL+Space
- mcl file must be copied to uses/p1x appropriate folder
- for any PIC that should use this library
find mlk file (defs folder) and add pragama
#pragma SetLib(library_name_without_exstension)
in order to make compiler aware of this change
you must change PIC and revert again
to selected (to make compiler load libraries again)
or simply restart compiler
Downside of this way is that compiler will always load all mcl (library) files set in the mentiond mlk file in order to give function prototypes on CTRL+space. Although it does not affect the size of HEX file generated if you do not use those library functions, it may slow down compilation proccess if a lot of libraries are added this way as default.
First way is recommended if the library is used with a certain projects and the second way is recommended if the library is general purpose one and used often with a certain mcu.
Re: Make and use my own library
I tried to use same .mcl file MikroC and MikroP. But i couldnt.
Can i use same .mcl file in MikroC and MikroB and MikroP ? Is it possible ?
Thank You All ...
Can i use same .mcl file in MikroC and MikroB and MikroP ? Is it possible ?
Thank You All ...
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: Make and use my own library
Hello,
I believe that I have answered you here:
http://www.mikroe.com/forum/viewtopic.php?f=93&t=47231
Best regards.
I believe that I have answered you here:
http://www.mikroe.com/forum/viewtopic.php?f=93&t=47231
Best regards.