EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Math Library Does Not Work

Started by suprajr October 9, 2003
Hey all-

I'm using the IAR Embedded Workbench C compiler and my code includes 
the 

#include "math.h" 

line of code, and i try to use the float() function.  But the 
compiler gives me an error saying that float() is an unrecognized 
external function that cannot be found, etc. etc.

Anyone have a solution to this? I know in GCC i always typed the -lm 
to get the linker to include the math library.  But I dont know how 
i would do something like that using the IAR GUI.

Thanks


Beginning Microcontrollers with the MSP430

I am using the IAR workbench and I tried to include math.h and declared a
variable as float with no problems.  I am sorry but I am not familiar with
the function float ( ), only the data type.



-----Original Message-----
From: suprajr [mailto:suprajr@supr...]
Sent: Wednesday, October 08, 2003 11:18 PM
To: msp430@msp4...
Subject: [msp430] Math Library Does Not Work



Hey all-

I'm using the IAR Embedded Workbench C compiler and my code includes
the

#include "math.h"

line of code, and i try to use the float() function.  But the
compiler gives me an error saying that float() is an unrecognized
external function that cannot be found, etc. etc.

Anyone have a solution to this? I know in GCC i always typed the -lm
to get the linker to include the math library.  But I dont know how
i would do something like that using the IAR GUI.

Thanks






Yahoo! Groups Sponsor



<http://rd.yahoo.com/M%9395.3614674.4902533.1261774/D=egroupweb/S050053
78:HM/A24963/R=0/SIGo885gmo/*http:/hits.411web.com/cgi-bin/autoredir?c
ampU6&lineid614674egroupweb&pos=HM>



<http://us.adserver.yahoo.com/l?M%9395.3614674.4902533.1261774/D=egroupmai
l/S=:HM/A24963/randS0821647>


.



">http://docs.yahoo.com/info/terms/>  Terms of Service.






"suprajr" <suprajr@supr...> writes:

> I'm using the IAR Embedded Workbench C
compiler and my code includes
> the
>
> #include "math.h"
>
> line of code, and i try to use the float() function.  But the 
> compiler gives me an error saying that float() is an unrecognized 
> external function that cannot be found, etc. etc.
>
> Anyone have a solution to this? I know in GCC i always typed the -lm 
> to get the linker to include the math library.  But I dont know how 
> i would do something like that using the IAR GUI.

Hi!

In C there is no function called "float", it is a data type (just like
"int" and "double".)

There is no need to include a special math library; all is included in
the standard library provided by the compiler.

    -- Anders

I'm sorry i typed float(), i meant the function floor() didn't
work.
it seems no functions in the math library for the kickstart IAR 
embedded workbench work, i geuss its because its only Kickstart and 
not the full version.

--- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
> 
> "suprajr" <suprajr@h...> writes:
> 
> > I'm using the IAR Embedded Workbench C compiler and my code 
includes
> > the
> >
> > #include "math.h"
> >
> > line of code, and i try to use the float() function.  But the 
> > compiler gives me an error saying that float() is an 
unrecognized 
> > external function that cannot be found, etc.
etc.
> >
> > Anyone have a solution to this? I know in GCC i always typed 
the -lm 
> > to get the linker to include the math
library.  But I dont know 
how 
> > i would do something like that using the IAR
GUI.
> 
> Hi!
> 
> In C there is no function called "float", it is a data type (just

like
> "int" and "double".)
> 
> There is no need to include a special math library; all is 
included in
> the standard library provided by the compiler.
> 
>     -- Anders


Are you aware that only double and not float types are supported by the IAR
math library?  Also check you setting under Project/Options/General and make
sure the Target Processor Configuration matches the processor you are using
(i.e. hardware multiplier or not).  I see that I also have a line on my .XCL
file cl430m.r43 that is to load the C library with hardware multiplier
support.  I think the library names vary slightly in the kickstart version.

Gary Anderson.

----- Original Message -----
From: suprajr <suprajr@supr...>
To: <msp430@msp4...>
Sent: Sunday, October 12, 2003 7:24 PM
Subject: [msp430] Re: Math Library Does Not Work


> I'm sorry i typed float(), i meant the
function floor() didn't work.
> it seems no functions in the math library for the kickstart IAR
> embedded workbench work, i geuss its because its only Kickstart and
> not the full version.
>
> --- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
> >
> > "suprajr" <suprajr@h...> writes:
> >
> > > I'm using the IAR Embedded Workbench C compiler and my code
> includes
> > > the
> > >
> > > #include "math.h"
> > >
> > > line of code, and i try to use the float() function.  But the
> > > compiler gives me an error saying that float() is an
> unrecognized
> > > external function that cannot be found, etc. etc.
> > >
> > > Anyone have a solution to this? I know in GCC i always typed
> the -lm
> > > to get the linker to include the math library.  But I dont know
> how
> > > i would do something like that using the IAR GUI.
> >
> > Hi!
> >
> > In C there is no function called "float", it is a data type
(just
> like
> > "int" and "double".)
> >
> > There is no need to include a special math library; all is
> included in
> > the standard library provided by the compiler.
> >
> >     -- Anders
>
>
>
> .
>
>
>
> ">http://docs.yahoo.com/info/terms/
>
>



AFAIK, KickStart has no support at all for any type of floating point.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for MSP430 and ARM processors 

> Are you aware that only double and not float types
are 
> supported by the IAR math library?  Also check you setting 
> under Project/Options/General and make sure the Target 
> Processor Configuration matches the processor you are using 
> (i.e. hardware multiplier or not).  I see that I also have a 
> line on my .XCL file cl430m.r43 that is to load the C library 
> with hardware multiplier support.  I think the library names 
> vary slightly in the kickstart version.
> 
> Gary Anderson.
> 
> ----- Original Message -----
> From: suprajr <suprajr@supr...>
> To: <msp430@msp4...>
> Sent: Sunday, October 12, 2003 7:24 PM
> Subject: [msp430] Re: Math Library Does Not Work
> 
> 
> > I'm sorry i typed float(), i meant the function floor() 
> didn't work. 
> > it seems no functions in the math library for the kickstart IAR 
> > embedded workbench work, i geuss its because its only Kickstart and 
> > not the full version.
> >
> > --- In msp430@msp4..., Anders Lindgren <andersl@i...> wrote:
> > >
> > > "suprajr" <suprajr@h...> writes:
> > >
> > > > I'm using the IAR Embedded Workbench C compiler and my
code
> > includes
> > > > the
> > > >
> > > > #include "math.h"
> > > >
> > > > line of code, and i try to use the float() function.  But
the 
> > > > compiler gives me an error saying that float() is an
> > unrecognized
> > > > external function that cannot be found, etc. etc.
> > > >
> > > > Anyone have a solution to this? I know in GCC i always typed
> > the -lm
> > > > to get the linker to include the math library.  But I dont
know
> > how
> > > > i would do something like that using the IAR GUI.
> > >
> > > Hi!
> > >
> > > In C there is no function called "float", it is a data
type (just
> > like
> > > "int" and "double".)
> > >
> > > There is no need to include a special math library; all is
> > included in
> > > the standard library provided by the compiler.
> > >
> > >     -- Anders
> >
> >
> >
> > .
> >
> >
> >
> > ">http://docs.yahoo.com/info/terms/
> >
> >
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> ---------------------~--> Buy Ink Cartridges or Refill Kits 
> for your HP, Epson, Canon or Lexmark Printer at MyInks.com. 
> Free s/h on orders $50 or more to the US & Canada. 
http://www.c1tracking.com/l.asp?cidU11
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/CFFolB/TM
---------------------------------~->

.

 

">http://docs.yahoo.com/info/terms/ 



"suprajr" <suprajr@supr...> writes:

> I'm sorry i typed float(), i meant the
function floor() didn't work.
> it seems no functions in the math library for the kickstart IAR
> embedded workbench work, i geuss its because its only Kickstart and
> not the full version.

No, the kickstart library contains floating point support, so there
must be something else...

I just made a simple test program (see below) that I compiled with
both the supplied libraries.  You can try it out and see if it works.
If it works you can try to check how it differs from your setup.
(Maybe it's something simple, like maybe youre applications contains
another function or variable named "floor"?)

If if doesn't work it could be interesting to know which type of error
you get.  (Is is the compiler is linker that complains?  What is the
actual error message?  Which library are you using?  etc.)

/--------------------------
#include <stdio.h>
#include <math.h>

void test(double x)
{
  printf("floor(%g) => %g\n", x, floor(x));
}


int main()
{
  test(1.5);

  test(-1.5);

  return 0;
}
\--------------------------

    -- Anders
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.


The 2024 Embedded Online Conference