[英]Build Fail 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我檢查了文件的存在。
所以我嘗試在源文件夾中使用所需的 header 文件將 #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
所以,我知道問題的根源是什么。 Cygwin 中的路徑格式存在問題,或者更確切地說,Windows 和 Linux 路徑格式之間的交互存在問題。 我可以通過將 Makefile 中的路徑從 Linux /home/folder 更改為 Windows D:\home\folder\ 格式來解決該問題。
更詳細的答案初學者:在“Makefile.incl”修改2行可能會解決問題。 在上述情況下,“Makefile.incl”假設位於 ~/STM32/stm32f103c8t6 文件夾中。
以下是“Makefile.incl”中的行
#TOP_DIR:= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TOP_DIR:= C:\xyz\home\STM32\stm32f103c8t6
#OPENCM3_DIR:= $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/libopencm3)
OPENCM3_DIR:= c:/xyz/home/STM32/stm32f103c8t6/libopencm3
路徑中的“\”或“/”無關緊要
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.