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.

 

8 REPLIES 8
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.

Thank you AMars.4 for your reply.

I have placed the function under the /* USER CODE BEGIN 0 */ in main.c

The Model.cpp remains the same (unchanged).

In the build results, "the warning for main.c 'Adc_OutPut_GetValue' defined but not used" disappear; thank you.

The current STM32CubeIDC build results:

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.

09:28:32 Build Failed. 2 errors, 1 warnings. (took 1m:34s.826ms)

 

and the print screen:

EY1_0-1738367877334.png

 

The build error, Model.cpp:31: undefined reference to `Adc_Output_GetValue' is still remained.

Not sure how to overcome this.

 

Enclosed also the updated main.c

 

Thank you very much for your time and support. I look forward to hearing your advice.

 

With best regards

EY1

AMars.4
Associate III

The function in main doesn't match what you are calling from the model because of the upper case "P".

Change from "P" to "p" in the two places in main.c that you need to.... 

"Adc_Output_GetValue" instead of `Adc_OutPut_GetValue"

Every reference has to match exactly.

Thank you AMars.4.

Thank you very much for your advice. I have fixed this function name error in main.c. The project can now be built in STM32CubeIDE, and working in the STM32H7B3I-DK Board.

The following are the two print screens:

EY1_0-1738451266536.png

EY1_2-1738451348527.png

Thank you very much for your support. I greatly appreciate all your help.

With best regards

EY1

 

 

Hello @EY1 ,

If you were able to solve your issue, please put the a best answer so other can find the solution easily.

 

Best regards,

Louis BOUDO
ST Software Developer | TouchGFX