<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>simple printf causes L103 linker error</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/42991/simple-printf-causes-l103-linker-error</link><description> 
I haven&amp;#39;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 &amp;quot;stdio.h&amp;quot; and links in C51FPL.LIB.
Others LIBs don&amp;#39;t seem to link correctly</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/150193?ContentTypeID=1</link><pubDate>Fri, 04 May 2007 10:05:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ba1c63b1-6f85-45f5-9e3c-2587a31d7db5</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
Jon,&lt;/p&gt;

&lt;p&gt;
You&amp;#39;re a genius. That was the problem. I was manually linking a
particular LIB. I used to have to do that with the old Keil software
and just ported it over to the new project. If I take out the LIB
from my link, all memory models link fine. Thanks.&lt;/p&gt;

&lt;p&gt;
Sutton&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/149745?ContentTypeID=1</link><pubDate>Fri, 04 May 2007 09:54:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c707cb1c-f2c5-4f1e-9d16-2e804eb9fc35</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;&lt;p&gt;
Are you MANUALLY forcing the library that the link should link
with?&lt;/p&gt;

&lt;p&gt;
If so, that may be the problem.&lt;/p&gt;

&lt;p&gt;
The compiler tells the linker which Keil libraries to include so
there is no need for you to do that.&lt;/p&gt;

&lt;p&gt;
For example, C51S.LIB is the small model library. C51FPS.LIB is
the small model library floating-point extensions. To link a small
model application with floating-point, you need both of these
libraries linked in. Note that the compiler and linker do this
automatically and there is no need for you to do anything.&lt;/p&gt;

&lt;p&gt;
If you get the problems you get when using the command line to
compile and build but you don&amp;#39;t get them when you use uVision, then
you should tell uVision to create a batch file for building the
project and you should review that to see what the differences
are.&lt;/p&gt;

&lt;p&gt;
Jon&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/150198?ContentTypeID=1</link><pubDate>Fri, 04 May 2007 09:45:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c2d23c07-7175-4e15-a6cc-3816b04c923b</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
OK. I was wrong on the terminology.&lt;/p&gt;

&lt;p&gt;
Also, I am using the command line for compiling and linking, when
I get these linker errors. Seems to work OK in uVision. But, I still
don&amp;#39;t know why the command line linker errors are happening.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/149742?ContentTypeID=1</link><pubDate>Fri, 04 May 2007 09:32:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:03b11671-7fa3-4328-a9c1-deaee86bc020</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;I know what the S,C, and L memory modules stand for&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
NB: It&amp;#39;s mod&lt;i&gt;&lt;b&gt;el&lt;/b&gt;&lt;/i&gt; - not mod&lt;i&gt;&lt;b&gt;ule&lt;/b&gt;&lt;/i&gt;.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/149241?ContentTypeID=1</link><pubDate>Fri, 04 May 2007 08:48:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8bbd62da-1444-4912-820a-bb88596b28f2</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
I know what the S,C, and L memory modules stand for. I&amp;#39;ve been
using them for many years. But, that still doesn&amp;#39;t answer the
question of:&lt;/p&gt;

&lt;p&gt;
&amp;#39;sprintf&amp;#39; compiles and links fine with a Compact memory module but
ONLY with the small libraries (C51S.LIB). It does NOT link properly
with the compact or large LIBs (C51C.LIB or C51L.LIB). It gives L103
errors. Why? So, another question is what is the correlation between
the memory modules and the LIBS? My first inclination is nothing.
Sorry for being so long winded, but none of the postings have
answered my question. Please try again.&lt;/p&gt;

&lt;p&gt;
And actually, if I compile and link a simple &amp;#39;sprintf&amp;#39; statement
with a small memory module with C51FPS.LIB, I get L121 (Invalid
Fixup) errors. Why is that? All my variables are explicitly defined
as IDATA (or XDATA or whatever). If I link it with C51S.LIB, no
problems.&lt;/p&gt;

&lt;p&gt;
Sutton&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/148819?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 16:58:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a6e4e21f-2ec9-4265-8269-4b9ec9acad7e</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;My simple code compiles and links properly with C51S.LIB (but
not with other LIBs - L103 error). Still would like to know why that
is.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
The answer to that is in my very first reply in your original
thread.&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Hint:&lt;/b&gt; The &amp;#39;S&amp;#39; in C51&lt;b&gt;S&lt;/b&gt;.LIB indicates that it is for
the &lt;b&gt;S&lt;/b&gt;mall memory model...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/138446?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 16:12:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c3929d3a-1850-4629-8be5-dcdc25072e5b</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
DOH....That was it. Should have figured that out myself.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/135004?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 15:33:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2a678f29-41d7-48ff-83d9-3b9697107742</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;p&gt;
Do you have ANSI integer promotion enabled?&lt;/p&gt;

&lt;p&gt;
The format string in your printf is &amp;quot;%d&amp;quot;, which is to say an
integer, which means 2 bytes for C51. However, you pass it &amp;quot;x&amp;quot;, which
is declared as char -- 1 byte. This means the actual data passed to
printf does not match what the format tells printf() to process, and
you will not get the expected results.&lt;/p&gt;

&lt;p&gt;
Keil introduced a &amp;#39;b&amp;#39; modifier for 1-byte integers, e.g.
&amp;quot;%bd&amp;quot;.&lt;/p&gt;

&lt;p&gt;
The alternative is to enable ANSI integer promotion, which means
ALL single-byte parameters to ALL functions will be passed as
two-byte integers instead of one byte. This usually means a fair
amount of extra, unneeded code.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/123810?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 14:55:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6c7d4021-fe1f-4cb5-9a62-f410a864f22d</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
My simple code compiles and links properly with C51S.LIB (but not
with other LIBs - L103 error). Still would like to know why that
is.&lt;/p&gt;

&lt;p&gt;
However, with this code,&lt;/p&gt;

&lt;p&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;/p&gt;

&lt;p&gt;
main()&lt;br /&gt;
{ unsigned char idata x, text[15];&lt;/p&gt;

&lt;p&gt;
x = 12; sprintf(text,&amp;quot;%d Volts&amp;quot;,x);&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;
the value of text is &amp;#39;3072 Volts&amp;#39; in my variable watchbox. The
value of x is always 12. There is something going on with the
arguments that sprintf has in the Keil LIB. However, there is no
source code in the Keil folders to look at. Anybody have any ideas
why this simple Keil sprintf is not working? Using V7.50 of the
compiler. Thanks.&lt;/p&gt;

&lt;p&gt;
Sutton&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/112852?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 12:30:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:031b6a25-8e4d-412b-ba8b-d6d67e4e9686</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
I&amp;#39;m using command line for this C51 project. I use uVision for my
ARM project. So, what kind of compiles and links do you want me to do
from the command line?&lt;/p&gt;

&lt;p&gt;
Also, I&amp;#39;ve found out that using either ROM(large) or ROM(compact)
does link in the printf and sprintf correctly with the C51S.LIB. So,
problem solved temporarily. It does not link, however, with C51L.LIB
or C51C.LIB (error L103). Why is that? Where do I find out how those
functions are defined in those LIBS. I guess that defines my ultimate
question(s).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/135003?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 12:08:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:66400e73-a4f6-40ef-9f99-8ff4ff7eab22</guid><dc:creator>doubt that my ISP Al Bradford</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sutton;&lt;br /&gt;
While I was typing my second post you answered my first post so we
are out about 90deg at present.&lt;br /&gt;
Let&amp;#39;s review quickly.&lt;br /&gt;
Set the Memory Model to Small.&lt;br /&gt;
Set the Code ROM Size to Large.&lt;br /&gt;
Review the Extension folder tabs for correct settings.&lt;br /&gt;
What device type are you using?&lt;br /&gt;
What On-Chip and/or Off Chip RAM and ROM setting do you have
set-up?&lt;br /&gt;
I will attempt to duplicate you problem.&lt;br /&gt;
Bradford&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/99182?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 12:01:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a07b1109-beae-4480-a99e-f76f83b10248</guid><dc:creator>doubt that my ISP Al Bradford</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sutton;&lt;br /&gt;
Just re-read your last post ans I indeed raised a smoke screen.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Yes, I am using the ROM(Large) option in the compile.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Selecting Code Rom Size Large: 64K program is the correct default.
This allows the compiler to use both LCALL/LJMP as well as ACALL/AJMP
instructions. It does not define a fixed requirement for Large
Libs.&lt;/p&gt;

&lt;p&gt;
Under the drop down dialog Components,Enviorment and Books, select
the Folders/Extensions tab and look at how the Tools Base Folder is
defined.&lt;br /&gt;
By default, it should be Using Setting from TOOLS.INI check box and
the Base Folder should point to your Keil installation.&lt;br /&gt;
If you have copied or moved your installations files, the tools.ini
file will be corrupted and the tools can&amp;#39;t access the correct Lib
folders.&lt;br /&gt;
In this case you can un-check the Settings box and browse each of the
folder entries to the correct directories even if they are in the
same position as the original installation. The Keil tools can then
locate correct lib files.&lt;br /&gt;
Bradford&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/123809?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 11:52:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:555c493f-e22a-4f08-a0d3-5e6a6da93fba</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;You should leave the memory model set at small and explicitly
define your large vars such as arrays and struct to xdata.&amp;quot;&lt;/p&gt;

&lt;p&gt;
I understand that. I can&amp;#39;t use the small model because of the code
restriction &amp;lt; 2K. I get IMPROPER FIXUP linker errors. I have
explicitly defined most of my variables to be XDATA long ago, so
that&amp;#39;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&amp;#39;t figured it
out yet. Compact or large module causes same error.&lt;/p&gt;

&lt;p&gt;
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&amp;#39;m
stuck until I do.&lt;/p&gt;

&lt;p&gt;
Sutton&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/112850?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 11:41:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a545cc45-ff45-48ff-accd-fcb39c0cc109</guid><dc:creator>doubt that my ISP Al Bradford</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sutton;&lt;br /&gt;
I don&amp;#39;t have a direct answer for your printf problem but I detect a
mis-understanding of memory models on your part.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;I can&amp;#39;t use the small LIB files, because my project code is
about 9K&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
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 &lt;b&gt;explicitly&lt;/b&gt; 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.&lt;br /&gt;
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.&lt;br /&gt;
I know a very indirect answer to your post and I hope I haven&amp;#39;t
raised another smoke screen for you.&lt;br /&gt;
Bradford&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/99194?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 11:02:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2f8235e2-3959-42d8-a534-45bec0b8d659</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
OK. When I used C51S.LIB, the simple file linked fine. Which
brings up the question of Why? I can&amp;#39;t use the small LIB files,
because my project code is about 9K. Using the compact module or the
large module doesn&amp;#39;t link correctly - same L103 error. I looked in
the A51 .pdf from Keil at the Linker section and couldn&amp;#39;t find
anything on the different LIBs in the Keil LIB folder.&lt;/p&gt;

&lt;p&gt;
Sutton&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/75067?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 10:39:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:67869e14-de2c-4d77-8c18-cdb532fb4826</guid><dc:creator>Sutton Mehaffey</dc:creator><description>&lt;p&gt;&lt;p&gt;
Yes, I am using the ROM(Large) option in the compile. I kept it
that way for this code snippet, because that is how it is set up in
my project code that exhibits the same linker error.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple printf causes L103 linker error</title><link>https://community.arm.com/thread/50701?ContentTypeID=1</link><pubDate>Thu, 03 May 2007 10:33:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5e0f5ede-6219-4c04-8ed0-0254455562be</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
So why did you have to start a new thread?&lt;br /&gt;
Why not continue in the existing thread?&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/forum/docs/thread9814.asp"&gt;http://www.keil.com/forum/docs/thread9814.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
C51FPL.LIB is the library for the Large memory model with
Floating-Point support.&lt;/p&gt;

&lt;p&gt;
Is your source compiled for the Large memory model?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>