pshahani wrote:
Hi,
I am new to msp430-gcc. I am working on the msp430f148 microcontroller, and
I have installed BSL on fedora 2
I want to find the square root of a number, and I have written the following
code:
#include <msp430x14x.h>
#include <math.h>
int main(void)
{
float number = 16.0;
float root;
root = sqrt(number);
return 0;
}
However, this does not work and gives me the following error:
msp430-gcc -mmcu=msp430x148 -o elf_file -O main.c
/tmp/ccIhjeE2.o: In function `main':
main.c:(.text+0x112): undefined reference to `sqrt'
make: *** [elf_file] Error 1
you need to link against the math library. The -l option tells gcc
which libraries to link in. -lm should do the trick (is sqrt fn for
floats is in the lib...)
I have tried converting float to double, but it still does not work.
Someone please help out asap. I need to fix this bug at the earliest. Also,
I am new to msp430-gcc, so please provide step by step solutions.
Thanks
Parikshit
--
View this message in context:
http://www.nabble.com/problem-using-sqrt%28-%29-t1419103.html#a3825202
Sent from the MSP430 gcc - Users forum at Nabble.com.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users