Hi, the problem is that you use a double function but mspgcc has only float functions. It works when you use floats:
#include<math.h> main() { float num = 40.0; float res; res = sqrtf(num); } > msp430-gcc -O2 -mmcu=msp430x149 -o main.elf main.c -lm That's because 99 % of the programs do use no floating point code and from the rest more than 99 % (.99 %) uses only floats. That's the reason why no MSP430 compiler has complex numbers (with complex numbers up to complex long double and complex NANs, complex infs) although it's in C99 and although you can use complex long double numbers on a PC with gcc. In ANSI-C that's standard conform because mspgcc is a freestanding implementation. And because double (and long double, complex long double) operations would be really slow on MSP430 and require much Flash they don't make much sense. Regards, Rolf mspgcc-users@lists.sourceforge.net schrieb am 07.07.05 15:21:53: > > We had reported a problem on 30 June 2005 regarding > failing to link math routines in msp430-gcc on Windows > platform. > > We have not been able to get a solution to that > problem yet. > > We subsequently installed msp430-gcc on Linux (FC3) > platform. We have the same problem that math routines > don't get linked. Can anyone help? > > We are using msp430-gcc ver 3.4.2 on FC3. We could > complile source code successfully, but could not link > math library. > > ** The source code (main2.c) is below: > > #include<msp430x14x.h> > #include<math.h> > main() > { > double num = 40.0; > double res; > res = sqrt(num); > } > > ** The command we tried: > > $msp430-gcc -mmcu=msp430x149 -o main main2.c -lm > > ** The error message we got: > > /tmp/cc4WCY3f.o(.text+0x1c): In function `main': > undefined reference to `sqrt' > > Regards, > Guruprasad > > > > > > > _______________________________________________________ > Too much spam in your inbox? Yahoo! Mail gives you the best spam protection > for FREE! http://in.mail.yahoo.com > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users