undefined reference to `_sbrk' when using atof() function
Posted: Sun Apr 13, 2014 4:45 pm
Hi,
I am trying to cast a string as a float in a function, I was successfully able to cast a string as an integer in the same function and I can compile the code without any errors as long as I comment out the atof() part.
my code is:
void cmd_color(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
float fx, fy;
char test[20];
strcpy(test, "123.456");
//test = 123.456;
// fx = atof(argv[0]);
fy = atof(test);
fx = 4.8;
// fy = 2.4;
chprintf(chp, "String values = %s , %s . Float values = %f , %f\r\n", argv[0], argv[1], fx, fy);
// Color(atof(x), atof(y));
//Color(atof(argv[0]), atof(argv[1]));
FindValues();
//printing ratios of the 3 primary LEDs
chprintf(chp, "Ratio of Red LED is %f \r\n", Ratior());
chprintf(chp, "Ratio of Green LED is %f \r\n", Ratiog());
chprintf(chp, "Ratio of Blue LED is %f \r\n", Ratiob());
}
the above code has been modified from its original context in order to try and debug it, my final aim/goal is to read two variable length strings argv[0] and argv[1] and use them as inputs for the function Color which takes two floats.
the compiler outputs this:
Compiling console.c
console.c:18:30: warning: 'chp' defined but not used [-Wunused-variable]
Linking build/ch.elf
/Users/maskari/Projects/arm/Toolchain/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1
I am using the make file provided to me by the ChibiOS demo for my board the discovery f4.
my compiler is arm-none-eabi version 4.7
I have the latest version of ChibiOS
any suggestions would be massively appreciated as this error is driving me nuts!
I am trying to cast a string as a float in a function, I was successfully able to cast a string as an integer in the same function and I can compile the code without any errors as long as I comment out the atof() part.
my code is:
void cmd_color(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
float fx, fy;
char test[20];
strcpy(test, "123.456");
//test = 123.456;
// fx = atof(argv[0]);
fy = atof(test);
fx = 4.8;
// fy = 2.4;
chprintf(chp, "String values = %s , %s . Float values = %f , %f\r\n", argv[0], argv[1], fx, fy);
// Color(atof(x), atof(y));
//Color(atof(argv[0]), atof(argv[1]));
FindValues();
//printing ratios of the 3 primary LEDs
chprintf(chp, "Ratio of Red LED is %f \r\n", Ratior());
chprintf(chp, "Ratio of Green LED is %f \r\n", Ratiog());
chprintf(chp, "Ratio of Blue LED is %f \r\n", Ratiob());
}
the above code has been modified from its original context in order to try and debug it, my final aim/goal is to read two variable length strings argv[0] and argv[1] and use them as inputs for the function Color which takes two floats.
the compiler outputs this:
Compiling console.c
console.c:18:30: warning: 'chp' defined but not used [-Wunused-variable]
Linking build/ch.elf
/Users/maskari/Projects/arm/Toolchain/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1
I am using the make file provided to me by the ChibiOS demo for my board the discovery f4.
my compiler is arm-none-eabi version 4.7
I have the latest version of ChibiOS
any suggestions would be massively appreciated as this error is driving me nuts!