cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX_STM32H7B3I-DK_Build Errors

EY1
Associate II

Dear Sir,

 

Hardware: STM32H7B3I-DK

Software: STM32MX 6.13.0 / STM32CubeIDE 1.17.0 / TouchGFX 4.24.1/ STM32Cube_FW_H7_V1.12.0

 

Start the project from TouchGFX, and then refer to STM32 Graphics Workshop (STM32H7BWorkshop2020_labs12345), to develop the details in Model.hpp, ModelListener.hpp, Model.cpp, and main.c, etc. Aiming to display a data from hardware side on the screen, at this stage it is just a float constant (as can be seen in main.c), later it will be data from an external ADC.

 

The project can display a float constant (the 1.5555) in the Simulator on TouchGFX (refer to Model.cpp file), but in STM32CubeIDE, there are 2 build errors as show below (As a result, unable to show the float constant from main.c on the screen.):

 

(Copy from the Console of STM32CubeIDE after build):

C:/TouchGFXProjects/ADC_Output_Display/TouchGFX/gui/src/model/Model.cpp:30: undefined reference to `Adc_Output_GetValue'

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:103: STM32H7B3I-DK.elf] Error 1

"make -j2 all" terminated with exit code 2. Build might be incomplete.

17:19:18 Build Failed. 2 errors, 1 warnings. (took 29s.943ms)

 

The Adc_Output_GetValue() has already been defined both in Model.cpp and main.c; so not sure what means the: undefined reference to ‘Adc_Output_GetValue’; and do not know what to do next.

 

Also do not understand the meaning of:

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:103: STM32H7B3I-DK.elf] Error 1

 

Could you please provide your advice, and suggestion about what to do?

 

Thank you very much for your attention and support.

 

With best regards

EY1

 

P.S.

The print screen for above project:

Simulator result:

EY1_0-1738140512229.png

STM32CubeIDE Build Results (below 2):

EY1_1-1738140572073.png

EY1_2-1738140722305.png

 

Also enclosed in the attachment is main.c

Model.cpp and Model.hpp are not allow to attach, due to the cpp and hpp extension.

So, enclose the Model.cpp content below:

 

Model.cpp

#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>

extern "C" {
extern float Adc_Output_GetValue(void);
}

Model::Model() : modelListener(0)
, tickCounter(0)
{
}

void Model::tick()
{

tickCounter++;
if ((tickCounter % 20) == 0)
{
if (modelListener != 0)
{
modelListener->notifyAdc_VoltChanged(getNewAdc_Volt());
}
}

}

float Model::getNewAdc_Volt()
{
#ifndef SIMULATOR
return Adc_Output_GetValue();
#else
// Implementation for simulator
return 1.5555;
#endif /*SIMULATOR*/
}

 

Thank you very much for your time and help.

 

4 REPLIES 4
LouisB
ST Employee

Hello @EY1 ,

Remember, when you are posting code, please use the code formatting for better readability.

LouisB_0-1738241564324.png


For your issue, in the simulator it work because it do not tries to get the real value. In the model try to add directly "include <main.h>" in the extern.

 

Best regards,
Louis B.

Louis BOUDO
ST Software Developer | TouchGFX
AMars.4
Associate III

Do you have the actual function defined in main.c? All I can see from what you posted is a declaration.

 

EDIT. Actually I see the problem from your main.c, you need to move your function definition to outside of main().

You have it defined in the while(1) loop, which is the wrong place. Put the definition outside of main and it should at least build, you can also remove the HAL_Delay:

 

float Adc_OutPut_GetValue(void);

float Adc_OutPut_GetValue(void)
{
  return 3.1416;
}

 

EY1
Associate II

Thank you LouisB and AMars.4 for your reply.

I have added #include <main.h>" in the extern in Model.cpp

and have moved the function out of the while(1) loop, first place it under /* USER CODE BEGIN 5 */ not working, then place the function under /* USER CODE BEGIN 1 */ inside int main(void); it still can not build. Getting the similar build errors from STM32CubeIDE:

C:/TouchGFXProjects/ADC_Output_Display/Core/Src/main.c:129:9: warning: 'Adc_OutPut_GetValue' defined but not used [-Wunused-function]

129 | float Adc_OutPut_GetValue(void)

       |         ^~~~~~~~~~~~~~~~~~~

C:/TouchGFXProjects/ADC_Output_Display/TouchGFX/gui/src/model/Model.cpp:31: undefined reference to `Adc_Output_GetValue'

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:103: STM32H7B3I-DK.elf] Error 1

"make -j2 all" terminated with exit code 2. Build might be incomplete.

11:22:34 Build Failed. 2 errors, 2 warnings. (took 17s.333ms)

 

Below the two print screens from STM32CubeIDE:

EY1_0-1738287521994.png
EY1_2-1738287609185.png

Enclosed also Model.cpp (as shown below) and the main.c as an attachment.

 

#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>

extern "C" {
    #include <main.h>
    extern float Adc_Output_GetValue(void);
}

Model::Model() : modelListener(0)
    , tickCounter(0)
{
}

void Model::tick()
{

    tickCounter++;
    if ((tickCounter % 20) == 0)
    {
      if (modelListener != 0)
      {
        modelListener->notifyAdc_VoltChanged(getNewAdc_Volt());
      }
    }

}

float Model::getNewAdc_Volt()
{
#ifndef SIMULATOR
    return Adc_Output_GetValue();
#else
    // Implementation for simulator
    return 1.5555;
#endif /*SIMULATOR*/
}

 

Thank you very much for your attention and support. I look forward to hearing from you both.

With best regards

EY1

 

 

 

 

AMars.4
Associate III

Your function is still in the wrong place, it needs to be outside of the main function. 

Place it in the /* USER CODE BEGIN 0 */ section.