0

I'm working with C in Sourcery CodeBench IDE, programming in a STM32F10X, and when I compile this code

int main(void){

RCC_Configuration();

/* NVIC configuration */
NVIC_Configuration();

/* GPIO configuration */
GPIO_Configuration();

SysTick_Configuration();

Timer_Configuration();

dxl_initialize( 0, 1 );
USART_Configuration(USART_PC, Baudrate_PC);

GoalPos1[0]= 333;
GoalPos1[1]= 333;
GoalPos2[0]=690;
GoalPos2[1]=690;
GoalPos5[0]=412;
GoalPos5[1]=412;
GoalPos6[0]=611;
GoalPos6[1]=611;
GoalPos7[0]=355;
GoalPos7[1]=355;
GoalPos8[0]=664;
GoalPos8[1]=664;
double t = 1.0;

while(1)
{
    bMoving = dxl_read_byte( id, P_MOVING );
    CommStatus = dxl_get_result();
    if( CommStatus == COMM_RXSUCCESS )
    {
        if( bMoving == 0 )
        {
            if(t<=2){GoalPos3[0]=(int)(-1.5*t+300.7);GoalPos3[1]=(int)(-1.5*t+300.7);}else{GoalPos3[0]=298;GoalPos3[1]=298;}if(t<=2){GoalPos4[0]=(int)(1.5*t+721.0);GoalPos4[1]=(int)(1.5*t+721.0);}else{GoalPos4[0]=724;GoalPos4[1]=724;}GoalPos9[0]=(int)(0.0001661*t*t*t*t*t*t+0.0006153*t*t*t*t*t-0.1318*t*t*t*t+1.254*t*t*t+2.925*t*t-43.64*t+527.9);GoalPos9[1]=GoalPos9[0];GoalPos10[0]=(int)(0.0003296*t*t*t*t*t*t-0.01189*t*t*t*t*t+0.2032*t*t*t*t-2.895*t*t*t+27.86*t*t-109.9*t+613.8);GoalPos10[1]=GoalPos10[0];GoalPos11[0]=(int)(-0.006659*t*t*t*t*t*t+0.2862*t*t*t*t*t-4.584*t*t*t*t+33.35*t*t*t-105.1*t*t+102.1*t+379.3);GoalPos11[1]=GoalPos11[0];GoalPos12[0]=(int)(0.000823*t*t*t*t*t*t-0.01887*t*t*t*t*t-0.09102*t*t*t*t+5.247*t*t*t-44.36*t*t+130.7*t+528.9);GoalPos12[1]=GoalPos12[0];GoalPos13[0]=(int)(-0.003788*t*t*t*t*t*t+0.1389*t*t*t*t*t-1.64*t*t*t*t+5.74*t*t*t+7.459*t*t-24.55*t+297.2);GoalPos13[1]=GoalPos13[0];GoalPos14[0]=(int)(0.002975*t*t*t*t*t*t-0.1283*t*t*t*t*t+2.114*t*t*t*t-16.1*t*t*t+50.88*t*t-38.08*t+744.6);GoalPos14[1]=GoalPos14[0];GoalPos15[0]=(int)(-0.007288*t*t*t*t*t*t+0.3476*t*t*t*t*t-6.384*t*t*t*t+55.4*t*t*t-219.1*t*t+301.6*t+492.8);GoalPos15[1]=GoalPos15[0];GoalPos16[0]=(int)(0.001997*t*t*t*t*t*t-0.07483*t*t*t*t*t+0.881*t*t*t*t-2.857*t*t*t-5.658*t*t+27.76*t+378.4);GoalPos16[1]=GoalPos16[0];GoalPos17[0]=(int)(-0.0002364 *t*t*t*t*t*t+0.02187*t*t*t*t*t-0.5432 *t*t*t*t+4.617*t*t*t-6.029*t*t-49.48*t+537.6);GoalPos17[1]=GoalPos17[0];GoalPos18[0]=(int)(0.000729*t*t*t*t*t*t-0.03161*t*t*t*t*t+0.5943 *t*t*t*t-7.041*t*t*t+52.96*t*t-183.3*t+664.7); GoalPos18[1]=GoalPos18[0];
            Posicao();
        }

        PrintErrorCode();

        // Read present position
        wPresentPos = dxl_read_word( id, P_PRESENT_POSITION_L );
        TxDWord16(GoalPos[INDEX]);
        TxDString("   ");
        TxDWord16(wPresentPos);
        TxDByte_PC('\r');
        TxDByte_PC('\n');
    }
    else
        PrintCommStatus(CommStatus);
    t = t + 0.01;
}
return 0;}

When I run it, give this message:

C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to __aeabi_dcmple' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to__aeabi_dmul' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to __aeabi_dadd' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to__aeabi_d2iz' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to __aeabi_dmul' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to__aeabi_dadd' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to __aeabi_d2iz' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to__aeabi_dmul' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to __aeabi_dmul' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to__aeabi_dmul' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to __aeabi_dmul' C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: undefined reference to__aeabi_dmul' APP/src/main.o:C:\Users\Gilmar\Dropbox\L008 - Bloco Delta\Trabalho\pdpd\PDPD LIBS\CM530\09 DXL READ_WRITE/APP/src/main.c:179: more undefined references to `__aeabi_dmul' follow

How may I solve this problem? When I comment the line t = t + 0.01, the code Works, but I need to add 0.01. I have already tried with float,double and int, any number when I put lonely, works, my problem is only in the sum.

  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – too honest for this site Aug 25 '16 at 20:39
  • You certainly do not **run** this code! Sidenote: don't use floating point - less `double` on that arch! Use fixed-point arithmetic with integers. (Note: that is also the reason for your problems, try to understand the names of the missing symbols!) – too honest for this site Aug 25 '16 at 20:40
  • And there is no "embedded C". – too honest for this site Aug 25 '16 at 20:45
  • the error messages are indicating a line 179 in main.c However the posted code is only 58 lines long. So the posted code has nothing to do with the error messages. Please either post the resulting error messages from the posted code or post the actual code that the posted error messages go with. – user3629249 Aug 27 '16 at 00:47
  • the posted code will NEVER compile. Amongst many other reasons, the required statements of the type: `#include <...h>` are missing – user3629249 Aug 27 '16 at 00:48

1 Answers1

1

Your compiler needs an implementation of a soft float library to handle floating point arithmetic. The undefined symbols indicate that the compiler isn't linking against a soft float implementation.

I don't know if you need double precision, but I'd advice against using it if possible - single precision float would be less painful for the architecture. You need to make sure your compiler is set up to use a suitable floating point ABI and that it has a suitable soft float implementation available. Your Cortex M3 doesn't have a hardware floating point unit.

Sultan
  • 138
  • 5