This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Static Library in keil

I have the ready-to-use code bundle for the controller i use. It came along with the development board.

The question is, should i create a *.lib file (with all the source files added to it)?
will it reduce the size of code as compared to adding all the source files?

kindly note that, I dont know how create a *.lib file in keil. will read the documents available on keil.
but m cautious about investing time if it does not have any specific advantage.

Parents
  • Yes, and that's why you often yabber on with irrelevant non-sense. Don't act foolishly, people won't mistake you for a fool.

    The behaviors of compilers, linkers, loaders, librarians, object files and toolsets is often critically dependent on the architecture or memory model applied. That and the competence of those who wrote the tools, or designed the object file format.

    Libraries typically allow the linker to cherry pick objects it needs vs doesn't need, as it establishes what code is needed and the dependency trees that sets up. The granularity still often remains at the object level, and a linker that can reject objects during dead code elimination is going to be successful, or at least could be, whether that file is passed on the command line or part of a library.

    The purpose of defining a function (subroutine) as it's own object/section, is again to separate it from other surrounding code and the permit the function to be eliminated if it is never used anywhere. This shrinks the granularity from the larger object file, to the function level. Something that's clearly beneficial when identifying dead code.

Reply
  • Yes, and that's why you often yabber on with irrelevant non-sense. Don't act foolishly, people won't mistake you for a fool.

    The behaviors of compilers, linkers, loaders, librarians, object files and toolsets is often critically dependent on the architecture or memory model applied. That and the competence of those who wrote the tools, or designed the object file format.

    Libraries typically allow the linker to cherry pick objects it needs vs doesn't need, as it establishes what code is needed and the dependency trees that sets up. The granularity still often remains at the object level, and a linker that can reject objects during dead code elimination is going to be successful, or at least could be, whether that file is passed on the command line or part of a library.

    The purpose of defining a function (subroutine) as it's own object/section, is again to separate it from other surrounding code and the permit the function to be eliminated if it is never used anywhere. This shrinks the granularity from the larger object file, to the function level. Something that's clearly beneficial when identifying dead code.

Children
  • Some compilers can automatically (possibly after getting a specific compiler flag) place the functions of a source file into separate regions, to allow the linker to cherry-pick at a much finer level than than grabbing complete object files.

    An example for gcc:
    elinux.org/Function_sections

    That makes it much easier with the source code management of libraries - it's no fun to move each individual function into a separate source file. Extra extreme to have a C++ class where each member methods has to be placed into separate source files just so the linker can include just the member methods that are actually used by the program.

    On the other hand - Keils 8051 compiler can perform code optimization during the actual linking, which is quite uncommon.
    http://www.keil.com/support/docs/2297.htm

    So architecture and selected tools can make a huge difference in what is the correct answer to a question.

  • Yes, and that's why you often yabber on with irrelevant non-sense. Don't act foolishly, people won't mistake you for a fool.
    well people can think anything they want.

    i m not an expert and hence, bound to make mistakes. But am ready to correct them and willing to learn. Thats what matters for me. As long as my knowledge increases, i have no problem with what others have to think or do.

  • i have no problem with what others have to think or do.

    That's a cute rule of thumb.

    But think about your reputation and the perceptions being nurtured by your actions.

    Look back through this forum and you'll see posters aplenty who've said something crazy and been ridiculed from there on in.

    It's also interesting to see some who've received the same response for the slightest misdemeanour.

    And then it's particularly interesting to see those who manage to pose as experts when it is quite clear that they don't know what they're talking about.

    There's likely to be other categories you recognise.

    So, best to be sensible.

  • It's also interesting to see some who've received the same response for the slightest misdemeanour.
    I think its not a misdemeanour to post a wrong message, if the poster is ready to accept his mistake and more importantly learn.

    Well my understanding of forum is different.
    I think that there are some people who are more experienced than others _which may not mean that they know all the correct answers in the world_
    many times the OPs don't know how to proceed to solve the problem. we are here to guide OP (and in the process we also are learning _clearing concepts_ from each other). but rather, i some times feel that people are here waiting for an opportunity to belittle some one.


    But think about your reputation and the perceptions being nurtured by your actions

    may be is a good piece of advise.

  • but rather, i some times feel that people are here waiting for an opportunity to belittle some one.

    Indeed. Of that I am sure.

    For these individuals, the word hubris springs to mind.

  • i some times feel that some people here are waiting for an opportunity to belittle some one