guide to creating your own libraries in mC

General discussion on mikroC.
Author
Message
gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

guide to creating your own libraries in mC

#1 Post by gambrose » 08 Mar 2005 12:46

Could you give a guide to creating your own libraries in mC it doesn’t seem to pick up my library files if I just copy the mcl files into the uses folder.
Graham Ambrose

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

Re: guide to creating your own libraries in mC

#2 Post by pizon » 08 Mar 2005 17:29

This (copy/paste to the <Uses> dir) should work. You might have named your libraries in an 'unfortunate' manner, e.g. to end with C_F, or E_A or similar (take a look in the <Defs> files).

BTW, if you're testing your libraries from within the same project you used to create them, don't forget to exclude their sources from the project.
pizon

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#3 Post by gambrose » 08 Mar 2005 17:49

My library is called “P16_Decimal_2_BCD.mcl” and I have copied and pasted to the uses/P16 dir, I’m using a P16F877A

And I have excluded the original source file.

But get:
  • Undeclared identifier[Short2BCD] in expression
    Undeclared identifier[Int2BCD] in expression
    Undeclared identifier[Long2BCD] in expression
Graham Ambrose

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

#4 Post by pizon » 11 Mar 2005 12:59

Have you #included the header file?
pizon

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#5 Post by gambrose » 11 Mar 2005 13:12

I wasn't sure if I had to include a header file as you do not have to do this to use the built in functions.

When I do include the header file I get the following error:
_Short2BCD function not found
Graham Ambrose

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

#6 Post by rajkovic » 11 Mar 2005 16:45

gambrose wrote:My library is called “P16_Decimal_2_BCD.mcl” and I have
Name of your library may not contain underscores (_) if you want compiler to load it automatically. There are special (rather obscure) rules how compiler loads libraries with underscores in their names.

Now, I would advise you to be patient, and wait till April. In new version, we'll try to keep it as simple and clear as possible. All this we discussed here will be changed with new linker, so this knowledge might prove to be useless within 3-4 weeks.

-

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#7 Post by gambrose » 14 Mar 2005 20:07

Renamed my file Decimal2BCD16 and created new mcl still no joy. :cry:
Graham Ambrose

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#8 Post by gambrose » 14 Mar 2005 20:10

I though I would try restarting mC and it works now :D
Graham Ambrose

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#9 Post by gambrose » 14 May 2005 21:30

Can't seem to get mikroC to see I library I created with it. :(

I called it BCD16.
Graham Ambrose

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

#10 Post by rajkovic » 15 May 2005 15:28

gambrose wrote:Can't seem to get mikroC to see I library I created with it. :(

I called it BCD16.
In V.2 we made changes. In Defs folder you have files of type *.mlk for each
PIC. All you have to do is to add to wanted chip *.mlk next line

Code: Select all

#pragma SetLib(name_of_Library_no_extesion)
put *.mcl in Uses folder, one *.mcl for p16, and one for p18 that was built for target family. then reopen project and

:wink:

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#11 Post by gambrose » 15 May 2005 16:27

Is it possible to put

Code: Select all

#pragma SetLib(name_of_Library_no_extesion)
in the code of the project you what to use the library for rather than the chip *.mlk file?
Graham Ambrose

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

#12 Post by rajkovic » 15 May 2005 18:21

gambrose wrote:Is it possible to put

Code: Select all

#pragma SetLib(name_of_Library_no_extesion)
in the code of the project you what to use the library for rather than the chip *.mlk file?
for now not, maybe next version

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#13 Post by gambrose » 15 May 2005 18:30

Are there any plans for a library project option in the IDE which would install your created libraries when you compiled them?

Or maybe some library managing tools.
Graham Ambrose

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#14 Post by zristic » 15 May 2005 23:00

gambrose wrote:...IDE which would install your created libraries when you compiled them?
Or maybe some library managing tools.
We will consider this, it is a good idea.

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#15 Post by gambrose » 19 May 2005 13:30

I tried to install a mikroC library file i wrote in mikroBasic but i haven't been able to get it to work.

I have copied the mcl files to mikroBasic/uses/p16
and edited the mlk file to add #pragma statement.

but mikroBasic dose not recognize the function names in the library.

I am right in thinking that this should work aren't i
Graham Ambrose

Post Reply

Return to “mikroC General”