Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
double a = 123456.0;
double b = 65432.0;
double c ;
int d = 5;
c= a+b;
c= a-b;
c= a*b;
c= a/b;
printf("%lf",c);
return EXIT_SUCCESS;
}
Some errors occur:
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:22: undefined reference to `__adddf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:22: undefined reference to `__adddf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:23: undefined reference to `__subdf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:23: undefined reference to `__subdf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:24: undefined reference to `__muldf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:24: undefined reference to `__muldf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:25: undefined reference to `__divdf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:25: undefined reference to `__divdf3'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:27: undefined reference to `printf'
C:\Andestech\AndeSight201MCU\mcu_64\workspace\float_test\Debug/../src/float_test.c:27: undefined reference to `printf'
This is because we set "-nostdlib" to avoiding default library. Delete this option can solve the problem.
Attachment:
solution.png [ 80.42 KiB | Viewed 7832 times ]
Sample code: (This have link errors)
Attachment:
float_test.zip [13.42 KiB]
Downloaded 842 times
Reference:
http://stackoverflow.com/questions/2187 ... pplication