linux下調(diào)用math.h編譯出錯(cuò)undefinde reference to 'sin'
如果直接gcc編譯,會(huì)出現(xiàn)未定義的情況:
/tmp/ccbS6FZx.o: In function `main':
fft.c:(.text+0x71): undefined reference to `sin'
fft.c:(.text+0x9f): undefined reference to `sin'
fft.c:(.text+0x25e): undefined reference to `pow'
fft.c:(.text+0x2d5): undefined reference to `pow'
fft.c:(.text+0x45e): undefined reference to `pow'
fft.c:(.text+0x548): undefined reference to `sqrt'
/tmp/ccbS6FZx.o: In function `Wn_i':
fft.c:(.text+0x64d): undefined reference to `cos'
fft.c:(.text+0x674): undefined reference to `sin'
collect2: error: ld returned 1 exit status
是因?yàn)槿鄙僬{(diào)用,具體需要添加-lm進(jìn)行編譯
gcc a.c -o a -lm
其中a.c為源代碼,a為編譯后輸出結(jié)果, -lm為gcc選項(xiàng)
在編譯即可。
*博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請(qǐng)聯(lián)系工作人員刪除。