博客專欄

        EEPW首頁 > 博客 > linux下調用math.h編譯出錯undefinde reference to 'sin'

        linux下調用math.h編譯出錯undefinde reference to 'sin'

        發布人:machinnneee 時間:2021-06-01 來源:工程師 發布文章

        如果直接gcc編譯,會出現未定義的情況:

        /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

        是因為缺少調用,具體需要添加-lm進行編譯

        gcc a.c -o a -lm

         其中a.c為源代碼,a為編譯后輸出結果, -lm為gcc選項

        在編譯即可。

        *博客內容為網友個人發布,僅代表博主個人觀點,如有侵權請聯系工作人員刪除。



        關鍵詞: linux math

        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 思南县| 都兰县| 金阳县| 革吉县| 丰镇市| 独山县| 洪江市| 吴堡县| 江城| 漾濞| 黄大仙区| 中超| 木里| 荣昌县| 阳新县| 大洼县| 乌鲁木齐市| 修武县| 鹿泉市| 综艺| 乐山市| 阿拉善左旗| 赤城县| 永川市| 鸡东县| 荆门市| 收藏| 巢湖市| 上思县| 白沙| 祁门县| 三门峡市| 满城县| 饶河县| 安丘市| 枣阳市| 兴山县| 怀集县| 湘乡市| 东至县| 江源县|