看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) linux 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) math.h 問題(Question): 我在linux上用gcc寫c code 需要用到math.h中的function, 可是用的時候都會寫undefined reference to 'cosf', 其他要用到的function也是如此, 請問有辦法下載到math.h放到我的資料夾底下用嗎? 3Q -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.64.10
ckclark:gcc -lm xxx.c 08/24 02:17
1. 請問一下 我是要在arm simulator下使用的 用arm的cross compiler也可以使用這個-lm的指令嗎? 2. 我google了一下, 好像都沒有math.h的source code, 所以math.h在gcc底下, 是一定要加-lm才能使用嗎? 3. 所以如果以上兩種都不行的話, 就要我自己一個function一個function, 想辦法自己刻出來瞜XD? ※ 編輯: guanrulee 來自: 140.113.64.10 (08/24 02:51)
johnlinvc:是emulator 還是simulator 兩個不一樣 08/24 10:06
johnlinvc:emulator 的話就要看他的 系統lib 有沒有 math.h 08/24 10:07
johnlinvc:理論上 ARM 有支援 ISO C所以一定會有 math.h 08/24 10:10
tropical72:有啊!方法不只一種啊! 08/24 11:33
tropical72:= = 對不起,我剛在丟水球,搞笑了。 08/24 11:33
tropical72:若你compiler環境真的沒有,要自己造的話, 08/24 11:38
tropical72:http://www.netlib.org/fdlibm/ ,但速度不會快. 08/24 11:39
guanrulee:3Q 我在研究看看 08/24 14:29
guanrulee:因為現在發現simulator還沒有float功能 08/24 14:29
guanrulee:我還要把它都改成fixed point 囧 08/24 14:29
tropical72:何謂沒 float 功能 ? 不支援 double/float,只算整數 ? 08/24 14:37
guanrulee:對 我們目前使用的 不支援float double 08/24 14:38
tropical72:問題愈來愈雜,待回文吧。 08/24 14:40
tropical72:先自提一下,可能會用到哪些 math.h 為佳。 08/24 14:49
tropical72:如三角函式、捨進位函式、次方函式等,會用到哪些 ? 08/24 14:54
tropical72:< 話說有compiler不能用 floating,讓人感到不可思議 > 08/24 14:56
guanrulee:log sin cos sqrt exp atan ceil floor atan2 08/24 15:36
tropical72:你都不能用flaoting 了,ceil / floor 還有意義嗎? 08/24 15:40