關於TouchGFX生成MDK5工程編譯報錯:xxx: error: #5: cannot open source input file "xxx": No such file or directory的解決方法


TouchGFX軟件版本:4.14.0

MDK5軟件版本:V5.29.0.0

STM32CubeMX軟件版本:6.0.1

開發板:STM32F769I_DISCO

桌面系統:Window10

TouchGFX選擇開發板STM32F769I_DISCO,應用模板為空白模板,點擊生成代碼,完成后,用MDK5打開編譯后報錯,提示找不到C++的頭文件hpp文件,這個報錯一度困擾我很久,最后偶然找到解決方法。

Build started: Project: STM32F769I_DISCO
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
*** Warning: You are compiling one or more files of source type C++ and have selected 'use MicroLIB'. MicroLIB does not support C++!
  
Build target 'STM32F769I_DISCO'
assembling startup_stm32f769xx.s...
compiling Buttons.cpp...
../TouchGFX/target/Buttons.cpp(39): error:  #5: cannot open source input file "touchgfx/hal/Buttons.hpp": No such file or directory
  #include <touchgfx/hal/Buttons.hpp>
../TouchGFX/target/Buttons.cpp: 0 warnings, 1 error
compiling CortexMMCUInstrumentation.cpp...
../TouchGFX/target/CortexMMCUInstrumentation.hpp(4): error:  #5: cannot open source input file "platform/core/MCUInstrumentation.hpp": No such file or directory
  #include <platform/core/MCUInstrumentation.hpp>
../TouchGFX/target/CortexMMCUInstrumentation.cpp: 0 warnings, 1 error
compiling KeySampler.cpp...
../TouchGFX/target/KeySampler.hpp(42): error:  #5: cannot open source input file "platform/driver/button/ButtonController.hpp": No such file or directory
  #include <platform/driver/button/ButtonController.hpp>
../TouchGFX/target/KeySampler.cpp: 0 warnings, 1 error
compiling STM32TouchController.cpp...
../TouchGFX/target/STM32TouchController.hpp(23): error:  #5: cannot open source input file "platform/driver/touch/TouchController.hpp": No such file or directory
  #include <platform/driver/touch/TouchController.hpp>
../TouchGFX/target/STM32TouchController.cpp: 0 warnings, 1 error
compiling TouchGFXHAL.cpp...
../TouchGFX/target/generated/TouchGFXGeneratedHAL.hpp(20): error:  #5: cannot open source input file "touchgfx/hal/HAL.hpp": No such file or directory
  #include <touchgfx/hal/HAL.hpp>
../TouchGFX/target/TouchGFXHAL.cpp: 0 warnings, 1 error
compiling TouchGFXGPIO.cpp...
../TouchGFX/target/TouchGFXGPIO.cpp(18): error:  #5: cannot open source input file "touchgfx/hal/GPIO.hpp": No such file or directory
  #include <touchgfx/hal/GPIO.hpp>
../TouchGFX/target/TouchGFXGPIO.cpp: 0 warnings, 1 error
compiling TouchGFXConfiguration.cpp...
../TouchGFX/target/generated/TouchGFXConfiguration.cpp(17): error:  #5: cannot open source input file "texts/TypedTextDatabase.hpp": No such file or directory
  #include <texts/TypedTextDatabase.hpp>
../TouchGFX/target/generated/TouchGFXConfiguration.cpp: 0 warnings, 1 error
compiling TouchGFXGeneratedHAL.cpp...
../TouchGFX/target/generated/TouchGFXGeneratedHAL.hpp(20): error:  #5: cannot open source input file "touchgfx/hal/HAL.hpp": No such file or directory
  #include <touchgfx/hal/HAL.hpp>
../TouchGFX/target/generated/TouchGFXGeneratedHAL.cpp: 0 warnings, 1 error
compiling app_touchgfx.c...
compiling STM32DMA.cpp...
../TouchGFX/target/generated/STM32DMA.cpp(20): error:  #5: cannot open source input file "touchgfx/hal/OSWrappers.hpp": No such file or directory
  #include <touchgfx/hal/OSWrappers.hpp>
../TouchGFX/target/generated/STM32DMA.cpp: 0 warnings, 1 error
compiling OSWrappers.cpp...
../TouchGFX/target/generated/OSWrappers.cpp(17): error:  #5: cannot open source input file "touchgfx/hal/OSWrappers.hpp": No such file or directory
  #include <touchgfx/hal/OSWrappers.hpp>
../TouchGFX/target/generated/OSWrappers.cpp: 0 warnings, 1 error
compiling stm32f7xx_it.c...
compiling freertos.c...
compiling main.c...
compiling otm8009a.c...
compiling stm32f7xx_hal_timebase_tim.c...
compiling stm32f7xx_hal_msp.c...
compiling ft6x06.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal.c...
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...
compiling stm32f7xx_hal_dma2d.c...
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_sdram.c...
compiling stm32f7xx_ll_fmc.c...
compiling stm32f7xx_hal_dsi.c...
compiling stm32f7xx_hal_ltdc_ex.c...
compiling stm32f7xx_hal_ltdc.c...
compiling stm32f7xx_hal_qspi.c...
compiling system_stm32f7xx.c...
compiling stm32f7xx_hal_tim_ex.c...
compiling croutine.c...
compiling stm32f7xx_hal_tim.c...
compiling event_groups.c...
compiling list.c...
compiling stream_buffer.c...
compiling queue.c...
compiling timers.c...
compiling tasks.c...
compiling heap_4.c...
compiling port.c...
compiling cmsis_os2.c...
"STM32F769I_DISCO\STM32F769I_DISCO.axf" - 10 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:12

  

話不多說,直接介紹我的解決方法:

其實很簡單,就一句話:先用TouchGFX建造工程,並生成代碼工程,生成的工程文件夾里面有一個STM32CubeMX的工程文件,打開,再用STM32CubeMX生成代碼工程(不要改變任何配置,包括工程路徑和名字,除了一點,下面會提到)。然后,再一次用TouchGFX生成代碼工程,之后用MDK5打開工程就可以正常編譯通過了!

注意:

  =》工程目錄下會有兩個STM32CubeMX工程文件,例如我的兩個文件是:STM32F769I_DISCO.ioc和backup_STM32F769I_DISCO.ioc,打開前者,后者是備份文件,無需理會。

  =》如果用STM32CubeMX打開文件出現如圖所示提示,點擊中間的“Migrate”按鈕

  =》在Project Manage選項卡里面,Toolchain/IDE選項默認是STM32CubeIDE,將其改為MDK-ARM,版本號的話,筆者選的是V5.27,其他版本號沒有測試過。注意,在用STM32CubeMX的過程中,只有這一點需要修改,其他不要改動!

 

  =》再次打開TouchGFX的這個工程(筆者用STM32CubeMX時是關閉TouchGFX的,打開沒試過),點擊右上角Generate Code再一次生成代碼工程,完畢后,打開MDK編譯即可通過。

  =》編譯通過后會有一個警告:STM32F769I_DISCO.sct(18): warning: L6314W: No section matches pattern *.o(ExtFlashSection).,這是因為這個應用模板是空白模板,沒有任何數據存在外部flash中,什么圖片啊,字體啊什么的。所以這個警告無需理會,要想驗證的話可以在TouchGFX中隨便顯示張圖片,這個警告就會消失了。親測有效。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM