arm-none-eabi-ld: cannot find -lm

arm-none-eabi-ld -Tuser/hc32l13x.lds -o grbl_hc32l13x.elf user/interrupts_hc32l13x.o user/system_hc32l13x.o user/main.o user/startup_hc32l13x.o -lm -Map=grbl_hc32l13x.map
arm-none-eabi-ld: cannot find -lm
makefile:33: recipe for target 'link' failed

改为在gcc时传入-T参数

$(CC)gcc $^ -Tuser/hc32l13x.lds $(LDFLAG) -Map=$(target).map -o $(target).elf

出错:arm-none-eabi-gcc: error: unrecognized command line option '-Map=grbl_hc32l13x.map'

再次改为:

$(CC)gcc $^ -Tuser/hc32l13x.lds $(LDFLAG) -Wl,-Map=$(target).map -o $(target).elf

编译通过。

附上.lds:

SECTIONS{
    . = 0;
    .text : {
        user/startup_hc32l13x.o
        *(.text)
    }
    .data : {
        *(.data)
    }
    .bss : {
        *(.bss)
    }
}
 
SECTIONS{
    . = 0;
    .text : {       /*写成 .text:{ 不对,要有空格。*/
        *(.text)    /*写成 *{.text} 不对,要为小括号。*/
    }
    .data : {
        *(.data)
    }
    .bss : {
        _sbss = .;         /* define a global symbol at bss start */
        __bss_start__ = _sbss;
        *(.bss)
        *(.bss*)
        *(COMMON)

        . = ALIGN(4);
        _ebss = .;         /* define a global symbol at bss end */
        __bss_end__ = _ebss;
    }
}

你可能感兴趣的:(日常BUG,arm开发,linux,运维)