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 Reply Children
  • PD I am NOT using uVision, because you can not replace the editor with CodeWright, this is DOS commandline.

    Erik

  • Erik,

    Does this mean you're compiling from within CodeWright too? How to you handle projects in CodeWright the way you can do it in uVision?
    I'm interested in how you manage this all, since I'm also using CodeWright very often for other programming environments, but not for Keil since I don't know how to manage the 'Keil' projects.
    I would like to know how you have set up your 'IDE' with CodeWright, if possible.

    --Geert

  • No IDE, not needed, runnig all from batchfiles.

    Erik

  • I use uv2 to create and maintain my projects. Then I configure buttons in CodeWright to build each project. For example, I assign one button to execute this command...
    c:\keil\uv2\uv2.exe -b -o %v%pvdriver.err %v%pvdriver.uv2 -t "Flash"

    and I assign another button to execute this command...
    c:\keil\uv2\uv2.exe -b -o %v%pvdriver.err %v%pvdriver.uv2 -t "Monitor"

    I also set up the error parser so I can click on the error in CodeWright's output window and it takes me to the appropriate line in the source code.

    This can all be done in CodeWright's Project Properties dialog box.

    -Walt

  • could you please post the howto for CodeWright users
    I also set up the error parser so I can click on the error in CodeWright's output window and it takes me to the appropriate line in the source code.

    Even with this posted, I will have a small problem since I do not compile from the source code. In order to maintain 117 projects with various levels of commonality, I "pick and choose" sourcefiles from several places and (while renaming some) combine them into a build directory. Obviously editing in the build directory will not make any changes hold since these files are moved in from elsewhere.

    I love CodeWright as an editor, but I have one small beef: They have made it so "flexible" that it takes days of reading the manual to find out how to use the flexibility. Fortunetely, I figured out a long time ago with Brief how to set up the editing configurationj.

    Erik

  • could you please post the howto for CodeWright users
    Sure, its the least I can do since it was members of this forum that help me figure out how to do it.

    http://www.keil.com/forum/docs/thread840.asp

    I will attempt to put something together today but in the next couple days for sure. It would help if I could include screen shots but I don't think there is anyway for me to do that using this forum. Is it acceptable to those interested to create a pdf and email it to you directly or should I stick to text and post it here?

    -Walt

  • Is it acceptable to those interested to create a pdf and email it to you directly

    absolutely, however
    or should I stick to text and post it here?
    If you can post it here with a link to the pdf etc would be even better.

    Erik

  • Hi Erik,

    Let's give this a try. If this doesn't work, I'll email it to you and anyone else that wants it.

    ftp.crown.com/.../codewright.pdf

    -Walt

  • it works well, I'll have a look.

    Thanx,

    Erik