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

Putting main() into a library

Hello,

i'm trying to solve the following situation: building a library which contains some functions and also main().

The goal is, to use this as a framework and link it with a user supplied module which only contains some callback functions.

Building up the library is not the problem. Listing it with LIB51 shows:

DOS LIBRARY MANAGER LIB51 V4.01
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 1997
LIBRARY: MYLIB.LIB
>LIB_FUNC
>>F_MY_LIB_FUNCTION
>LIB_MAIN
>>MAIN

(>'s added because the forum doesn't support blanks at beginning of line :-)

So main() seems to be put in the library as i want it.


The problem is linking it with the user supplied module. The linker does not find a root segment. So i tried to add main() as a root segment by specifying

overlay(* ! MAIN)

as a linker option. But the linker never finds main() at all.

Here's my complete linker call:

L51 user.obj, mylib.lib to mytest.abs ramsize(256) XD(0000h) overlay(* ! MAIN)


It results in:

*** WARNING 11: CANNOT FIND SEGMENT OR FUNCTION NAME
NAME: MAIN

*** WARNING 16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?F_THE_CALLBACK?USER

*** WARNING 10: CANNOT DETERMINE ROOT SEGMENT

(where F_THE_CALLBACK is a user supplied function called from within main() )

So, even the overlay manager seems not to "see" main.

Where's my mistake? Is main() processed different from other functions? Is it impossible to put main() into a library?

Thanks in advance for your help.

FRANK

Parents
  • I do not understand your problem; however I know you can put main() in a library, I do (it is in axmain.obj).

    if not exist Xlib.lib goto usliex
    del Xlib.lib
    :usliex
    c:\c51\bin\lib51 c Xlib.lib			>..\trash\trashbin
    c:\c51\bin\lib51 a axmain.obj   to Xlib.lib	>..\trash\trashbin
    c:\c51\bin\lib51 a ........ 	to Xlib.lib	>..\trash\trashbin abt 10 such lines
    
    c:\c51\bin\bl51 usstart.obj, axinthdr.obj, usasmfn.obj, Xlib.lib, c51s.lib TO x.abs RS(256) IX >protl.log
    

    Erik

Reply
  • I do not understand your problem; however I know you can put main() in a library, I do (it is in axmain.obj).

    if not exist Xlib.lib goto usliex
    del Xlib.lib
    :usliex
    c:\c51\bin\lib51 c Xlib.lib			>..\trash\trashbin
    c:\c51\bin\lib51 a axmain.obj   to Xlib.lib	>..\trash\trashbin
    c:\c51\bin\lib51 a ........ 	to Xlib.lib	>..\trash\trashbin abt 10 such lines
    
    c:\c51\bin\bl51 usstart.obj, axinthdr.obj, usasmfn.obj, Xlib.lib, c51s.lib TO x.abs RS(256) IX >protl.log
    

    Erik

Children