"no float in printf: link with -lm"
amossam
Posts: 35
Hey
I'm using libtiny, and getting this:
function strtof return value in type double.
I tried with -lm in compiler line, to build my program, i tried rebuilding libtiny with that argument, but no difference.
I even tried to remove libtiny, and use stdio.h, but no help...
any hints? and yes, I need printf with float, at least for now...
thx
I'm using libtiny, and getting this:
"no float in printf: link with -lm"from propeller when i use this line:
printf("X %f ", strtof(val));
function strtof return value in type double.
I tried with -lm in compiler line, to build my program, i tried rebuilding libtiny with that argument, but no difference.
I even tried to remove libtiny, and use stdio.h, but no help...
any hints? and yes, I need printf with float, at least for now...
thx
Comments
thx for fast reply...
i suspected that, so I removed libtiny, and replaced tinyio.h with stdio.h, but no difference!? and I triple checked that there is no reference to libtiny in my project...
The header file does not determine the library being linked. Probably you have libtiny.a linked somewhere either via project manager or other linker options. You can check the build status. Right-click select-all, copy, paste here if you are not sure.
Well, I don't use SimpleIDE, but Eclipse with my Makefile...
and I did 'find . | xargs grep tiny' in my project folder, and that came out empty...
Bu anyway, here is my Makefile...
and this is verbose output of make
i even tried to compile it manually from terminal, with almost no flags to gcc, and still the same...
this is probably then from last night... :blank: i tried zillion combinations...
CFLAGS states like this:
and curious thing, with or without -lm flag, resulting filesize that is uploaded to propeller is same to a byte!!
when i come home after work, i'll try to create a simplest program using printf with %f and then will see...
thx
-lm shouldn't be in CFLAGS at all, it's a linker stage option, not a compile option. And CFLAGS shouldn't be part of the linking stage. should be changed to something like this:
-Tor
ok, it seems that that is the point! now, when i put -lm just before -o (last parameter) it gives me following error:
so, i suppose that now math library gets included, but it won't fit.... but that is some other problem! :cool: (maybe XMMC memory model?)
thx for help
Try using 32bit doubles and/or simple printf.
We have discussed ways to reduce code size for a while and are on the verge of adding it.
For the time being XMMC is a fair option. It works with 64KB EEPROM, but it is slower than LMM.
yea, I found that and on propgcc wiki page I found some explanations, so now I'm using this:
and with help of __simple_printf it still fits in LMM. :-D
I still haven't tried 32bit doubles, but I did noticed one thing...
i have some decimal numbers stored in char*. I tried using atof function, but it puts on 5th or 6th decimal place sometimes instead of 0 some random number, but if I use double, that doesn't happen!
i don't know is that normal...
since I'm parsing that char* anyway, i added code that if some chars are numbers it converts them to decimal number. and if I use float now, it's storing numbers correctly. also, it seems that my way is faster than atof (at least what I can see!)! :-D
Can you provide an example? Did you try strtod instead of atof by chance?
Glad you have an alternative you like.
well, I created an example program and data, but it seems that main problem was my misunderstanding of float type capacity/accuracy, so it wasn't atof fault (but it is slower! :cool:) ...
strtod gives same result, because of float type capacity...
my apologies, I haven't studied enough what is the problem, instead I jumped to first suspect! :blank:
anyway, here is code
and here is data: