用keil建全新的project写了空白的main函数后编译报错(sct(7): error: L6236E:和axf: Error: L6218E:)


编译报错

.\Objects\LED-GPIO.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.

 

由于没有加启动文件,双击左边工程框的文件夹,添加Startup开头的.s文件即可。若keil生成的里没有,可以用一个能编译通过的例程序(根据你的MDK确定的),拷贝工程中的“***.s”文件加到自己的工程目录中。

 

编译再次报错

.\Objects\LED-GPIO.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32f103xb.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 1 error messages.

是这段代码中调用了SystemInit 但未声明

; Reset handler
Reset_Handler    PROC
                 EXPORT  Reset_Handler             [WEAK]
     IMPORT  __main
     IMPORT  SystemInit
                 LDR     R0, =SystemInit
                 BLX     R0
                 LDR     R0, =__main
                 BX      R0
                 ENDP

第一种:在工程当中任意一个C文件中加入SystemInit函数的定义,定义为空函数就可以正常编译。

void SystemInit()
{
    //do nothing 
}

第二种:注释掉(汇编程序,注释用 “;”)

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  __main
;               IMPORT  SystemInit
;               LDR     R0, =SystemInit
;               BLX     R0               
                LDR     R0, =__main
                BX      R0
                ENDP

 

*启动文件添加路径

 

 

 

 

 

 

 

 

 

 

 


 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM