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

simple printf causes L103 linker error

I haven't received an answer that fixed my problem, so here is another example.

I have a simple printf statement that causes a L103 error. No variables declared. Includes "stdio.h" and links in C51FPL.LIB. Others LIBs don't seem to link correctly either. Code compiles fine. Anyone know what the linking problem could be?

#include "stdio.h"

main()
{ printf("12345");
}

BL51 BANKED LINKER/LOCATER V5.12
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2004

*** ERROR L103: EXTERNAL ATTRIBUT DO NOT MATCH PUBLIC SYMBOL: ?_PRINTF?BYTE MODULE: C51FPL.LIB (PRINTF)

Program Size: data=15.1 xdata=48 code=2562
LINK/LOCATE RUN COMPLETE. 0 WARNING(S), 1 ERROR(S)

Parents
  • OK. When I used C51S.LIB, the simple file linked fine. Which brings up the question of Why? I can't use the small LIB files, because my project code is about 9K. Using the compact module or the large module doesn't link correctly - same L103 error. I looked in the A51 .pdf from Keil at the Linker section and couldn't find anything on the different LIBs in the Keil LIB folder.

    Sutton

Reply
  • OK. When I used C51S.LIB, the simple file linked fine. Which brings up the question of Why? I can't use the small LIB files, because my project code is about 9K. Using the compact module or the large module doesn't link correctly - same L103 error. I looked in the A51 .pdf from Keil at the Linker section and couldn't find anything on the different LIBs in the Keil LIB folder.

    Sutton

Children
  • Sutton;
    I don't have a direct answer for your printf problem but I detect a mis-understanding of memory models on your part.

    I can't use the small LIB files, because my project code is about 9K

    The memory model dialog defines the implicit area for vars storage. Selecting the large memory model gives the compiler/linker permission to place all vars in xdata area. Bad for rapid access of frequently used vars. You should leave the memory model set at small and explicitly define your large vars such as arrays and struct to xdata. Also, define infrequently used vars to xdata and let the tools place locals and autos in data/idata areas. The tools can then over write any vars that go out of scope during program run.
    This will speed up your code and some what reduce code size but more important, correct libs can be selected by the compiler/linker tools.
    I know a very indirect answer to your post and I hope I haven't raised another smoke screen for you.
    Bradford

  • "You should leave the memory model set at small and explicitly define your large vars such as arrays and struct to xdata."

    I understand that. I can't use the small model because of the code restriction < 2K. I get IMPROPER FIXUP linker errors. I have explicitly defined most of my variables to be XDATA long ago, so that's not the issue. I simply want to use printf and sprintf in my code, but all links produce the L103 error. And, I haven't figured it out yet. Compact or large module causes same error.

    So, I found a simple snippet that produces the same error, but nobody seems to be able to figure out what the problem is. And, I'm stuck until I do.

    Sutton

  • Sutton;
    While I was typing my second post you answered my first post so we are out about 90deg at present.
    Let's review quickly.
    Set the Memory Model to Small.
    Set the Code ROM Size to Large.
    Review the Extension folder tabs for correct settings.
    What device type are you using?
    What On-Chip and/or Off Chip RAM and ROM setting do you have set-up?
    I will attempt to duplicate you problem.
    Bradford