Skip to main content
mSH.1
Associate III
Jun 21, 2022 11:54 PM UTC
Question

I inquire about TouchGFX Compile error.

hello

​

I inquire about TouchGFX Compile error.

​

To call a specific function by including discovery.h in Model.cpp

A compile error occurs.

​

However, in CubeIDE, it compiles normally and runs well.​

​

I want to know why a compile error occurs in TouchGFX and a normal compile in CubeIDE.

​

1.The development environment is as follows

​

  • STM32H725g-dk
  • CubleIDE 1.9.0
  • TouchGFX 4.19.1​

​

​

​2. The source of model.cpp is as follows.

===================================================================

​

#ifndef SIMULATOR

extern "C" {

#include "stm32H7xx.h"

#include "stm32h735g_discovery.h"

}

#endif

​

​

void Model::tick()

{

#ifndef SIMULATOR

​

  int button_sample = BSP_PB_GetState(BUTTONn); //BUTTONn // BUTTON_USER

  if (button_sample != 0x000F)

  {

    if( buttonState != button_sample )

    {

    modelListener->PUI_data(button_sample);

    buttonState = button_sample;

    }

  }

  else

  {

  buttonState = button_sample;

  }

}

​===================================================================

​

​

​

​

3.The error message in TouchGFX is as follows.

===================================================================

Compile

    make -f ../gcc/Makefile -j8

    Reading TouchGFX/application.config

    Compiling TouchGFX/gui/src/scrtopcook_screen/ScrTopCookView.cpp

    Compiling TouchGFX/gui/src/scrtopcook_screen/ScrTopCookPresenter.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrbottom_screen/ScrBottomViewBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrtopcook_screen/ScrTopCookViewBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrtopset_screen/ScrTopSetViewBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrauto_screen/ScrAutoViewBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrmain_screen/ScrMainViewBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrtop_screen/ScrTopViewBase.cpp

    Compiling TouchGFX/generated/gui_generated/src/scrloading_screen/ScrLoadingViewBase.cpp

    Compiling TouchGFX/generated/images/src/image_Pause.cpp

    Compiling TouchGFX/generated/images/src/BitmapDatabase.cpp

    Compiling TouchGFX/generated/images/src/image_restart.cpp

    Compiling TouchGFX/target/generated/TouchGFXGeneratedHAL.cpp

    Compiling TouchGFX/target/generated/TouchGFXConfiguration.cpp

    Linking TouchGFX/build/bin/target.elf

    TouchGFX/build/STM32H735G-DK/TouchGFX/gui/src/model/Model.o: In function `Model::tick()':

    c:\TouchGFXProjects\Noble_cooker/TouchGFX/gui/src/model/Model.cpp:29: undefined reference to `BSP_PB_GetState'

    collect2.exe: error: ld returned 1 exit status

    gcc/Makefile:293: recipe for target 'TouchGFX/build/bin/target.elf' failed

    make[2]: *** [TouchGFX/build/bin/target.elf] Error 1

    gcc/Makefile:289: recipe for target 'generate_assets' failed

    make[1]: *** [generate_assets] Error 2

    ../gcc/Makefile:49: recipe for target 'all' failed

    make: *** [all] Error 2

===================================================================

​

​

​

​

​

​

​

​

​

This topic has been closed for replies.

7 replies

MM..1
Super User
Jun 22, 2022 4:50 AM UTC

TouchGFX use different makefile as CUBE. You need add search path to added headers and add source files into TGFX makefile.

Andrew Neil
Super User
Jun 22, 2022 8:40 AM UTC

@MM..1​  but the posted error is not about problems finding a header file?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mSH.1
mSH.1Author
Associate III
Jun 22, 2022 5:10 AM UTC

​

thank you for your reply.

​

I don't know how to modify the makefile in TouchGFX.

Are there any guides provided?

​

Andrew Neil
Super User
Jun 22, 2022 8:47 AM UTC

@mSH.1​ "To call a specific function by including discovery.h in Model.cpp A compile error occurs. However, in CubeIDE, it compiles normally and runs well.​"

So the TouchGFX build is C++ - is the CubeIDE build also C++, or just plain C ?

This doesn't look right:

#ifndef SIMULATOR
extern "C" {
#include "stm32H7xx.h"
#include "stm32h735g_discovery.h"
}
#endif

Did you mean:

#ifdef __cplusplus
extern "C"
{
#endif
 
#include "stm32H7xx.h"
#include "stm32h735g_discovery.h"
 
#ifdef __cplusplus
}
#endif

0693W000008xsqBQAQ.png@mSH.1

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mSH.1
mSH.1Author
Associate III
Jun 22, 2022 9:29 AM UTC

hello ​@Andrew Neil​ 

​

Thanks for the useful feature.

​

As I was informed, the moel.cpp part was modified as follows.​

#ifdef __cplusplus
extern "C"
{
#endif
 
#include "stm32H7xx.h"
#include "stm32h735g_discovery.h"
 
#ifdef __cplusplus
}
#endif

​

But the same error occurs.

​It occurs only in touchGFX and compiles normally in CubeIDE.

​

​The error message in TouchGFX is as follows.

Run Simulator
 Generate
 Done
 Generate Assets
 make -f simulator/gcc/Makefile assets -j8
 Reading ./application.config
 Done
 Post Generate
 touchgfx update_project --project-file=simulator/msvs/Application.vcxproj
 Done
 Post Generate Target
 touchgfx update_project
 .project files generated inside project folder
 This is STM32CubeIDE project updater: Working on ../STM32CubeIDE/.project
 .cproject file: ../STM32CubeIDE/.cproject
 Float ABI: hard
 Writing STM32CubeIDE project file: ../STM32CubeIDE/.project
 Writing STM32CubeIDE project file: ../STM32CubeIDE/.cproject
 Done
 Compile
 make -f simulator/gcc/Makefile -j8
 Reading ./application.config
 Compiling gui/src/scrbottom_screen/ScrBottomView.cpp
 Compiling gui/src/scrbottom_screen/ScrBottomPresenter.cpp
 Compiling gui/src/scrtopcook_screen/ScrTopCookView.cpp
 Compiling gui/src/scrtopcook_screen/ScrTopCookPresenter.cpp
 Compiling gui/src/containers/CustomContainer_temp_wheel.cpp
 Compiling gui/src/scrtopset_screen/ScrTopSetPresenter.cpp
 Compiling gui/src/scrtopset_screen/ScrTopSetView.cpp
 Compiling gui/src/model/Model.cpp
 gui/src/model/Model.cpp:18:10: fatal error: stm32H7xx.h: No such file or directory
 #include "stm32H7xx.h"
 ^~~~~~~~~~~~~
 compilation terminated.
 generated/simulator/gcc/Makefile:196: recipe for target 'build/MINGW32_NT-6.2/gui/src/model/Model.o' failed
 make[2]: *** [build/MINGW32_NT-6.2/gui/src/model/Model.o] Error 1
 make[2]: *** Waiting for unfinished jobs....
 generated/simulator/gcc/Makefile:155: recipe for target 'generate_assets' failed
 make[1]: *** [generate_assets] Error 2
 simulator/gcc/Makefile:32: recipe for target 'all' failed
 make: *** [all] Error 2
 Failed
 Failed

Andrew Neil
Super User
Jun 22, 2022 9:59 AM UTC

@mSH.1​ "As I was informed, the moel.cpp part was modified as follows"

I don't know the context of that snippet, so don't know if it's actually what you wanted - but certainly the original didn't look right.

There may be other places in your code with similar issues?

Do you understand the issues of mixing C and C++, and why/when the extern "C" is required?

You are now getting errors due to not finding header files - so, as @MM..1​  said, you do need to adjust your include paths...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.