如何清除链接器错误? windows上交叉编译stm32

如何解决如何清除链接器错误? windows上交叉编译stm32

我正在尝试交叉编译一个简单的 c/cpp 文件,目标是 stm32f030F4P,我成功地设置了 CMake 文件,并且 cmake 成功地为 ninja 构建了 build.ninja 文件。 当我执行 ninja 时出现以下错误

PS C:\Users\varun\Desktop\Projects\stm32f030f4p\Firmware\Blinky\build> ninja.exe [1/1] 链接 CXX 可执行文件 .elf 失败:.elf cmd.exe /C "cd . && C:\DEV-TO~1\TOOLCH~1\GCC-AR~1\102020~1\bin\AR10B2~1.EXE -march=armv6-m -mcpu=cortex-m0 -mthumb -DSTM32F030x4 -Og -ggdb -Wall -Wextra -ffunction-sections -fdata-sections -ffreestanding -fno-builtin --specs=nano.specs -fno-rtti - fno-exceptions -Wno-volatile -std=c++1z -g CMakeFiles/.elf.dir/src/main.cpp.obj -o .elf && cd 。” c:/dev-to~1/toolch~1/gcc-ar~1/102020~1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../.. /../arm-none-eabi/bin/ld.exe: c:/dev-to~1/toolch~1/gcc-ar~1/102020~1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../.. /../arm-none-eabi/lib/thumb/v6-m/nofp\libg_nano.a(lib_a-exit.o): 在函数 exit': exit.c:(.text.exit+0x1e): undefined reference to _exit' collect2.exe 中:错误:ld 返回 1 退出状态忍者:构建 停止:子命令失败。附注

请找到我的 CMakeLists.txt。

 CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
    
    INCLUDE("CMake/arm-none-eabi.cmake")
    
    SET(CMAKE_C_STANDARD    11)
    SET(CMAKE_CXX_STANDARD  17)
    
    PROJECT(BLINKY VERSION 1.0.1 DESCRIPTION "Blinky Example")
    
    FILE(GLOB_RECURSE
        LDSCRIPTS
        "ldscripts/*.ld"
    )
    
    FOREACH(file ${LDSCRIPTS})
        SET(CMAKE_CAMKE_LINKER_FLAGS "${CAMKE_LINKER_FLAGS} -T \"${file}\" ")
    ENDFOREACH()
    
    #Setup project headers
    INCLUDE_DIRECTORIES(
    
    )
    
    #Setup porject sources
    FILE(GLOB_RECURSE
        APPLICATION_SOURCE
        "src/*.c"
        "src/*.cpp"
    )
    
    ADD_EXECUTABLE(${PROJECT}.elf ${APPLICATION_SOURCE})

请找到我的 arm-none-eabi.cmake(原谅复制粘贴工具链的名称,不知道取什么名字)

MESSAGE("Running : arm-none-eabi.cmake")

SET(CMAKE_SYSTEM_PROCESSOR  arm)
SET(CMAKE_SYSTEM_NAME       Generic)

SET(CMAKE_C_COMPILER_WORKS  TRUE)
SET(CMAKE_CXX_COMPILER_WORKS  TRUE)

SET(CMAKE_TRY_COMPILE_TARGTE_TYPE   STATIC_LIBRARY)

SET(TARGET      STM32F030x4)
SET(ARCH        armv6-m)
SET(CPU         cortex-m0)
SET(ARM_ISA     mthumb)

SET(CMAKE_C_COMPILER    arm-none-eabi-gcc)
SET(CMAKE_CXX_COMPILER  arm-none-eabi-g++)
SET(CMAKE_ASM_COMPILER  arm-none-eabi-g++)
SET(CMAKE_SIZE          arm-none-eabi-size)
SET(CMAKE_OBJDUMP       arm-none-eabi-objdump)
SET(CMAKE_OBJCOPY       arm-none-eabi-objcopy)

SET(OPTIMISATION Og)
SET(DEBUG "ggdb")

SET(CMAKE_COMMON_FLAGS  "-march=${ARCH} -mcpu=${CPU} -${ARM_ISA} -D${TARGET} -${OPTIMISATION} -${DEBUG} -Wall -Wextra -ffunction-sections -fdata-sections -ffreestanding -fno-builtin --specs=nano.specs")
SET(CMAKE_ASM_FLAGS     "${CMAKE_COMMON_FLAGS} ")
SET(CMAKE_C_FLAGS       "${CMAKE_COMMON_FLAGS} -std=gnull")
SET(CMAKE_CXX_FLAGS     "${CMAKE_COMMON_FLAGS} -fno-rtti -fno-exceptions -Wno-volatile -std=c++1z")
SET(CAMKE_LINKER_FLAGS  "${CMAKE_COMMON_FLAGS} -nostartfiles -Wl,-Map,\"${TARGET}.map\" --specs-nano.specs")

我的链接脚本是从 STM32CubeIDE 复制粘贴的

> /* Entry Point */ ENTRY(Reset_Handler)
> 
> /* Highest address of the user mode stack */
> _estack = ORIGIN(RAM) + LENGTH(RAM);  /* end of "RAM" Ram type memory */
> 
> _Min_Heap_Size = 0x200 ;  /* required amount of heap  */
> _Min_Stack_Size = 0x400 ; /* required amount of stack */
> 
> /* Memories definition */ MEMORY {   RAM    (xrw)    : ORIGIN =
> 0x20000000,LENGTH = 4K   FLASH    (rx)    : ORIGIN = 0x8000000,> LENGTH = 16K }
> 
> /* Sections */ SECTIONS {   /* The startup code into "FLASH" Rom type
> memory */   .isr_vector :   {
>     . = ALIGN(4);
>     KEEP(*(.isr_vector)) /* Startup code */
>     . = ALIGN(4);   } >FLASH
> 
>   /* The program code and other data into "FLASH" Rom type memory */  
> .text :   {
>     . = ALIGN(4);
>     *(.text)           /* .text sections (code) */
>     *(.text*)          /* .text* sections (code) */
>     *(.glue_7)         /* glue arm to thumb code */
>     *(.glue_7t)        /* glue thumb to arm code */
>     *(.eh_frame)
> 
>     KEEP (*(.init))
>     KEEP (*(.fini))
> 
>     . = ALIGN(4);
>     _etext = .;        /* define a global symbols at end of code */   } >FLASH
> 
>   /* Constant data into "FLASH" Rom type memory */   .rodata :   {
>     . = ALIGN(4);
>     *(.rodata)         /* .rodata sections (constants,strings,etc.) */
>     *(.rodata*)        /* .rodata* sections (constants,etc.) */
>     . = ALIGN(4);   } >FLASH
> 
>   .ARM.extab   : {
>     . = ALIGN(4);
>     *(.ARM.extab* .gnu.linkonce.armextab.*)
>     . = ALIGN(4);   } >FLASH
> 
>   .ARM : {
>     . = ALIGN(4);
>     __exidx_start = .;
>     *(.ARM.exidx*)
>     __exidx_end = .;
>     . = ALIGN(4);   } >FLASH
> 
>   .preinit_array     :   {
>     . = ALIGN(4);
>     PROVIDE_HIDDEN (__preinit_array_start = .);
>     KEEP (*(.preinit_array*))
>     PROVIDE_HIDDEN (__preinit_array_end = .);
>     . = ALIGN(4);   } >FLASH
> 
>   .init_array :   {
>     . = ALIGN(4);
>     PROVIDE_HIDDEN (__init_array_start = .);
>     KEEP (*(SORT(.init_array.*)))
>     KEEP (*(.init_array*))
>     PROVIDE_HIDDEN (__init_array_end = .);
>     . = ALIGN(4);   } >FLASH
> 
>   .fini_array :   {
>     . = ALIGN(4);
>     PROVIDE_HIDDEN (__fini_array_start = .);
>     KEEP (*(SORT(.fini_array.*)))
>     KEEP (*(.fini_array*))
>     PROVIDE_HIDDEN (__fini_array_end = .);
>     . = ALIGN(4);   } >FLASH
> 
>   /* Used by the startup to initialize data */   _sidata =
> LOADADDR(.data);
> 
>   /* Initialized data sections into "RAM" Ram type memory */   .data :
> {
>     . = ALIGN(4);
>     _sdata = .;        /* create a global symbol at data start */
>     *(.data)           /* .data sections */
>     *(.data*)          /* .data* sections */
>     *(.RamFunc)        /* .RamFunc sections */
>     *(.RamFunc*)       /* .RamFunc* sections */
> 
>     . = ALIGN(4);
>     _edata = .;        /* define a global symbol at data end */
> 
>   } >RAM AT> FLASH
> 
>   /* Uninitialized data section into "RAM" Ram type memory */   . =
> ALIGN(4);   .bss :   {
>     /* This is used by the startup in order to initialize the .bss section */
>     _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;   } >RAM
> 
>   /* User_heap_stack section,used to check that there is enough "RAM"
> Ram  type memory left */   ._user_heap_stack :   {
>     . = ALIGN(8);
>     PROVIDE ( end = . );
>     PROVIDE ( _end = . );
>     . = . + _Min_Heap_Size;
>     . = . + _Min_Stack_Size;
>     . = ALIGN(8);   } >RAM
> 
>   /* Remove information from the compiler libraries */   /DISCARD/ :  
> {
>     libc.a ( * )
>     libm.a ( * )
>     libgcc.a ( * )   }
> 
>   .ARM.attributes 0 : { *(.ARM.attributes) } }

最后c文件很简单

unsigned int counter;
int main(void)
{
    for(;;)
    {
        counter++;
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res