首页 > 解决方案 > 构建失败 arm-none-eabi-gcc

问题描述

我进入了《Beginning STM32》一书——Warren Gay。我尝试在 Cygwin 下构建源代码,但即使在 makefile 中指出了所需文件的路径,也找不到所需文件。文件夹libopencm3/cm3/scb.h中的文件位于路径中:/home /root/STM32/stm32f103c8t6/libopencm3/include所以正确的路径应该是/home/root/STM32/stm32f103c8t6/libopencm3/include/libopencm3/cm3/scb.h我检查了文件的存在。

所以我尝试在源文件夹中使用所需的头文件将#include 更改为#include "file.h" - 这很有效,但是在不同的源文件中有很多情况。

有什么建议可以解决这个问题或找到摆脱这个问题的方法吗?

非常感谢!

这是我从终端得到的。

[~/STM32/stm32f103c8t6]

$ make

make -C rtos/libwwg


make[1]: Entering directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg'
make -w -C ./src

make[2]: Entering directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg/src'
arm-none-eabi-gcc -Os -g -std=c99 -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd -Wextra -Wshadow -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -fno-common -ffunction-sections -fdata-sections -I/home/root/STM32/stm32f103c8t6/libopencm3/include -I/home/root/STM32/stm32f103c8t6//rtos/libwwg/include -I./rtos -I. -MD -Wall -Wundef -DSTM32F1 -I/home/root/STM32/stm32f103c8t6/libopencm3/include -I/home/root/STM32/stm32f103c8t6//rtos/libwwg/include -o usbcdc.o -c usbcdc.c

usbcdc.c:7:10: fatal error: libopencm3/cm3/scb.h: No such file or directory
7 | #include <libopencm3/cm3/scb.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

make[2]: *** [../../../Makefile.incl:111: usbcdc.o] Error 1
make[2]: Leaving directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg/src'
make[1]: *** [Makefile:8: all] Error 2
make[1]: Leaving directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg'
make: *** [Makefile:41: libwwg] Error 2

标签: c++cmakefilestm32

解决方案


所以,我知道问题的根源是什么。Cygwin 中的路径格式存在问题,或者更确切地说,Windows 和 Linux 路径格式之间的交互存在问题。我可以通过将 Makefile 中的路径从 Linux /home/folder 更改为 Windows D:\home\folder\ 格式来解决这个问题。


推荐阅读