When I include the "math.h" and use math function such as cos(), sin(), I found compiling error. How to solve this problem?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
When I include the "math.h" and use math function such as cos(), sin(), I found compiling error. How to solve this problem?
Can you copy/paste the compiling error?
Steve K.
Beaver,
Start with the documentation for the C compiler you are using. There is probably a choice of various run-time libraries with different levels of support for floating point functions. You are probably linking with the wrong library. If you are using single or double precision float, be sure that is available.
Regards, Clay
Here is the error in the compiler:
XXX@ubuntu:~/OMAP35x_SDK_1.0.2/hpi_ver5$ arm-none-linux-gnueabi-gcc -o hpi_demo_ver5 hpi_demo.c
/tmp/ccKI0BHQ.o: In function `fft_rec':
hpi_demo.c:(.text+0x480): undefined reference to `cos'
hpi_demo.c:(.text+0x4fc): undefined reference to `sin'
collect2: ld returned 1 exit status
The math library isn't getting linked in. At the end of the compile line, add -lm to link in libm.
Steve K.