Skip to main content
markusmueller19
Associate II
May 28, 2009
Question

Compilling with float?

  • May 28, 2009
  • 27 replies
  • 6108 views
Posted on May 28, 2009 at 13:24

Compilling with float?

    This topic has been closed for replies.

    27 replies

    markusmueller19
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    Hello,

    In my project I must use float numbers, but on compiling I become this error:

    undefined reference to `__aeabi_ui2f'

    undefined reference to `__aeabi_fdiv'

    I start the linker with this command:

    arm-none-eabi-ld -v -lgcc -LC:/WinARM/CodeSourcery/lib/gcc/arm-none-eabi/4.2.3/thumb -Tprj/STM32F103CB-ROM.ld -Map=main.map out/lib/src/cortexm3_macro.o out/src/main.o out/src/stm32f10x_it.o out/src/stm32f10x_vector.o out/src/analogout.o --output main.elf

    The path from parameter -L exists, the file libgcc.a, too.

    Or have I forgot a parameter?

    Thank you for help. Regards Markus.

    markusmueller19
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    I must. I have from a other project a lot of sources and I have not enought time to change inito integer.

    st3
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    Quote:

    In my project I must use float numbers,

    Must you?

    Why?

    In very many cases, integers or fixed-point are preferable - especially if you can't get the floating-point to work! 8-)

    sjo
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    yes but if you use gcc to link then you will not have a issue.

    I have never understand why people call ld directly.

    Cheers

    sjo

    markusmueller19
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    In a other forum have one person write me the right solution:

    ''Häng das -lgcc mal hinter die Liste von *.o Files.''

    sjo
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    Try calling the linker using the gcc driver, it will probably solve your problem, eg.

    arm-none-eabi-gcc -Wl,-LC:/WinARM/CodeSourcery/lib/gcc/arm-none-eabi/4.2.3/thumb -Tprj/STM32F103CB-ROM.ld,-Map=main.map out/lib/src/cortexm3_macro.o out/src/main.o out/src/stm32f10x_it.o out/src/stm32f10x_vector.o out/src/analogout.o -o main.elf

    Cheers

    sjo

    [ This message was edited by: sjo on 10-06-2008 15:08 ]

    markusmueller19
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    Yes, the arm-none-eabi-gcc can linking, too, and it is working.

    Thank you for help.

    asterix
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    Hi all,

    I've used Both Keil version 3.22 ( Free version 32K) and IAR EWARM v5.11 ( Free version 32K) , not yet GCC from CodeSourcery on a small routine using ''cos(), sin(), one addition , one multiplication and one division with only ''float'' variables using Keil ''MCBSTM32'' board at 8Mhz and I found that the same function is 7 time faster with IAR than using Keil floating librairies.

    I' very intersted to see the result with GCC :) and I'm wondering if you have experienced similar results ? which seems very strange and keil is not providing optimized floating libraries.

    Best Regards,

    Asterix.

    Ps: I've used #include ''math.h'' in the header files.

    [ This message was edited by: asterix.magigimix on 10-06-2008 17:47 ]

    16-32micros
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    Hi sjo, Asterix,

    I've done some basic measurements with RVCT ( Keil 3.22) and EWARM 5.11 from IAR using our Cortex-M3 and here is my function :

    #include

    #define __pi 3.14159265

    float var1 = __pi ;

    float var2 = __pi/2;

    float var0[10] = {0,0,0,0,0,0,0,0,0,0};

    int main(void)

    {

    var0[0]= cos(var1);

    var0[1]= sin(var1);

    var0[2]= sqrt(var1);

    var0[3]= atan(var1);

    var0[4]= var2 + var1;

    var0[5]= var2 * var1;

    var0[6]= var2 / var1;

    while(1);

    }

    Results are :

    Cortex-M3, Keil 3.22 compiler 32 bit floats,exact CPU cycles

    cos 41359

    sin 43389

    sqrt 3090

    atan 42243

    add 127

    mul 624

    div 445

    Cortex-M3, IAR 5.11 compiler 32 bit floats,exact CPU cycles

    cos 1864

    sin 1946

    sqrt 2725

    atan 3423

    add 40

    mul 33

    div 53

    I'm quite surprised too by the results, where I see that keil is completely off while using trigonometric libraries. May be I'm missing something here ? Could you please try the same at your end and tell me your results for GCC from codesourcery.

    Cheers,

    STOne-32.

    sjo
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:36

    that quite old version of the arm gcc compiler.

    i would check with a newer arm-eabi compiler, floating point performance is supposed to have improved quite a bit over the older arm-elf compiler.

    Cheers

    sjo