Problem with sin() and random()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with sin() and random()

357 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by trryt on Sat May 01 09:56:12 MST 2010
Today I wanted to do two easy things, which in C wouldn't make any problems anywhere else, but in LPCXpresso they did.
First I needed some sinus values, so I included math.h used sin() and got error on Build:
:/nxp/lpcxpresso_3.2/tools/bin/../lib/gcc/arm-none-eabi/4.3.3/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(_sincos.o): In function `_sincos':
_sincos.c:(.text._sincos+0x1f0): undefined reference to `errno'
collect2: ld returned 1 exit status
And in Problems tab:
Description    Resource    Path    Location    Type
make: *** [blinky.axf] Error 1    blinky        line 0    C/C++ Problem

Second, I needed some random values, so I included stdlib.h and there was no random() function there, it fought it is obvious in C implementation that there has to be this function there. So the questions are, what I have to do to use sin() and where can I find random().
0 Kudos
4 Replies

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon May 03 00:32:23 MST 2010
random() is not a standard C function - use rand() instead.
0 Kudos

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Sun May 02 01:50:30 MST 2010

Quote: trryt
I hoped that changing C libs may bring random to its place but it's still missing..


Try using rand() instead.
0 Kudos

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by trryt on Sat May 01 15:50:45 MST 2010
Thank you very much! Changing from Redlib (none) to Redlib (nohost) fixed the sin() problem. I hoped that changing C libs may bring random to its place but it's still missing..
0 Kudos

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Sat May 01 13:18:47 MST 2010

Quote: trryt
:/nxp/lpcxpresso_3.2/tools/bin/../lib/gcc/arm-none-eabi/4.3.3/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(_sincos.o): In function `_sincos':
_sincos.c:(.text._sincos+0x1f0): undefined reference to `errno'


Have a look at this...

http://knowledgebase.nxp.com/showthread.php?p=955
0 Kudos