math libs not included ?


#1

Hi. I’m using OAT 3.02, GCC, ADL. The following problem manifests only on Target mode.
I’m using some math.h C functions like sin() or floor().
When the linker runs I get on a tmp file:
/cygdrive/c/Digital/Software/Antares/Ver5/Hello_World/gcc/out/hello_world.c:99: undefined reference to `sin’
an so with every math.h function I use. I see also on this file that files like
libc.a, libgcc.a are succesfuly loaded but I don’t see any reference for libm.a where I think math.h definitions are. I tried re-installing OAT and creating new projects with OAT wizard with no success.
(Note: I’m including math.h on my c file!)


#2

good question.

A list would be very useful what functions can be used in gcc. (or in ads arm).

There is a floating point libary for Open At 2.1, but i have not tried yet but i don’t think that it can be used with other versions.

I have recently read the know problems in Open At 3.02 that
sprintf “%f” can be used with gcc, this caused meg a big headache long long long time ago, because in debug everything was ok.

tom


#3

sorry.

sprintf “%f” can not be used with gcc. (reset the module)


#4

Has Wavecom any comment on this ?


#5

I asked my Wavecom contact, and he help me about this problem:

  1. In the wmnew script addiotional options write the path to include library file as given below:
    Example:
    In Open AT Project Wizard in “wmnew script additional options” window write:
    -inc “C:\OpenAT\Tools\GCC\arm-elf\lib”

Click OK

  1. Go to the project directory and open the mak file <MyProject.mak> with WordPad. In the file there is a option for library list:
EXTERNAL_LIB_LIST = \

After that line, add a line with library path. For me this look like this:

EXTERNAL_LIB_LIST = \
/cygdrive/C/OpenAT/Tools/GCC/arm-elf/lib/thumb/interwork/libm.a \

That’s it. Now for Target Mode will work all math functions.


#6

It worked. Thanks a lot.


#7

Can anyone tell me how do i trace a floating point value ??

I calculate the value as below:

float slop;
slop = atan(num/den);

I want to debug the value of Slop but i think i cannot use the TRACE(()) ?

any suggestions ??

-Jiten


#8

Hi jiten9,

Please find the answer to your question below:

  1. If you are using ARM compiler to compile your applicaiton, then you can USE the TRACE () macro to print the floating point value. You can use the following statement :
    TRACE((1,“The value of slop is %f”,slop));
    There is no limiation in the usage of %f format string under ARM compiler.
  2. If you are using GCC compiler to compile your applcation, then you have to use some workaround to print the floating point value. This is because, in GCC if you use the %f format specifier, the module crashes. To circumvent, this problem, you should convert your floating point value to a string and then print the string value. For instance,
    ascii buffer[20];
    s16 mantissa, modified_value;
    wm_memset(buffer,’\0’,20);
    modified_value = (s16)slop *1000; //assuming slop contains
    //the
    // floating point value.
    mantissa = modified_value - (s16) slop;
    wm_sprintf(buffer,"%d.%03d",(s16)slop,mantissa);
    TRACE((1,buffer));

Please note that the above code will provide you with 3 digits of precision after the decimal point. You can increase the precision by increasing the multiplier value for “slop” variable.

Best Regards.


#9

Couldn´t make work…any other ideas? When I try to follow the procedure I fails I can never compile the code again…

Best Regards,

Henrique