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

Help in building library file

Hi,

Can anyone help me. I am preparing a hardware specific library using keil C-51 compiler.

I have created a library file myfun.lib, which contains 10 functions.

I have written a main C file main.C where i call only 1 function (declared in myfun.lib).

When compiled and linked, it was found that all the unused functions, variables from myfun.lib also utilises memory stack of processor.

As per my knowledge during linking, only those called functions are linked and rest is ignored means doesnt occupy any memory stack.

Can any one help me.

Saurabh

Parents
  • It all depends on how you went about making that library of yours. The traditional way is to split up a library in as many independent source files as you can sensibly manage. The resulting .lib file will thus be constructing from rather many .obj files.

    This makes it easier (or even possible, in the first place) for the linker to decide which parts of the library to link into your final executable image, and which to leave out.

    Some Linkers can break open an .obj file package and use only some of the parts inside. In the case of Keil, I think that would require the LX51 linker, though, which you may not have.

Reply
  • It all depends on how you went about making that library of yours. The traditional way is to split up a library in as many independent source files as you can sensibly manage. The resulting .lib file will thus be constructing from rather many .obj files.

    This makes it easier (or even possible, in the first place) for the linker to decide which parts of the library to link into your final executable image, and which to leave out.

    Some Linkers can break open an .obj file package and use only some of the parts inside. In the case of Keil, I think that would require the LX51 linker, though, which you may not have.

Children
No data