Jump to content
Sign in to follow this  
dkpic

How do you generate a lib file.

Recommended Posts

Guest Pavel

Library generation is not accessible from ide. Run compiler from command line and use the -lib option.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest Jim

Thanks for the info about creating a lib file, I have been

wondering about it too.  However, a little more information

about what is in a lib file, and how to use them would

be helpful.

 

When I compile a lib file (no main function) in the IDE, the

IDE is smart enough to tell me it wants to create a x.lib file,

so I don't see why it can't just do it...

 

When I compile from the command line to a lib file it doesn't

look like much is really output to the file.  What is supposed

to be there?

 

Since the functions in a lib file are not usually called by other

functions in the same file, the optimizer doesn't generate

the code for them.  If I tell it to generate code for un-called

functions, then I get all of the built in C++ stuff that I don't

need.

 

I am also assuming that to use a lib file, when I get one

working, I simply add it to the project; is this correct?

 

I know that this is a lot for one post, but some sort of lib

tutorial and/or information would be very helpful.

 

Keep up the good work.

 

Jim

Share this post


Link to post
Share on other sites

Try

 

1.) create an interface file

 

e.g. mylib.h

this file has defines the interface routine

e.g.

extern char myFirstRoutine(char :D;

 

 

2.) create your source code file

e.g. mylib.c

this file defines your code

e.g.

 

extern char myFirstRoutine(char B)

{

  your code lines

 ..

  b= b+1;

  return b;

 ..

 

}

 

3.)

goto dos-shell

type

c2cw -IP16F84.INC -O1 -lib myLib.c -omyLib.lib

 

 

4.) use your library

include help-file in your test-program

specify library you wan to use (I think you will find it under options / item default libraries..

 

Br

skywalker

Share this post


Link to post
Share on other sites

Thanks for the informative reply...

 

I set things up as you recommend, but it still doesn't work.

I think the lib file is being generated correctly, but I have

trouble using it.

 

There are a couple of things to note:

With the older version of the compiler there was an option

setting to include lib files in the build.  The new PicAnt IDE

doesn't have this, so I added the lib file to the project.

 

When I compile the main project I get the following in the

build dialog:

 

 UARTST~1.CPP

 DALLAS~1.LIB

 This is not a library file or it is corrupted (DALLAS~1.LIB)

 Done

 

I would like to hear from Pavel on this one, and maybe

see a simple example from him that really works.

 

I may continue trying this with a more simple example than

I am currently using...

 

Thanks,

Jim

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...