博客專欄

        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

        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 克东县| 望都县| 武平县| 永泰县| 万全县| 建始县| 清水县| 赣榆县| 湖北省| 阜南县| 杨浦区| 宁明县| 广丰县| 漠河县| 余姚市| 英超| 武冈市| 宜州市| 聊城市| 滦南县| 日喀则市| 达孜县| 卢氏县| 兰西县| 和平县| 兴和县| 泽库县| 正镶白旗| 关岭| 阳山县| 洱源县| 延边| 常德市| 绵阳市| 鲁甸县| 辛集市| 沙田区| 普兰县| 张家口市| 天津市| 宝鸡市|