Skip to main content
Senior III
May 27, 2024
Solved

'atexit' was not declared in this scope

  • May 27, 2024
  • 3 replies
  • 4508 views

I'm trying to build myself a TouchGFX project

The project runs and builds correctly via TouchGFX Designer but I'm unable to compile it with VSCode (cmake, ninja gcc)

 

 

[build] C:/TouchGFXProjects/Circle_UI/Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/sdl2/OSWrappers.cpp: In static member function 'static void touchgfx::OSWrappers::initialize()':
[build] C:/TouchGFXProjects/Circle_UI/Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/sdl2/OSWrappers.cpp:24:24: error: 'atexit' was not declared in this scope
[build] atexit(deinitialize);
[build] ^
[build] [174/177] Building CXX object CMakeFiles/TouchGFX.dir/C_/TouchGFXProjects/Circle_UI/Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/sdl2/HALSDL2_icon.cpp.obj
[build] [175/177] Building CXX object CMakeFiles/TouchGFX.dir/C_/TouchGFXProjects/Circle_UI/Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/sdl2/HALSDL2.cpp.obj
[build] C:/TouchGFXProjects/Circle_UI/Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/sdl2/HALSDL2.cpp: In member function 'virtual bool touchgfx::HALSDL2::sdl_init(int, char**)':
[build] C:/TouchGFXProjects/Circle_UI/Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/sdl2/HALSDL2.cpp:314:21: warning: unused variable 'transfer_thread' [-Wunused-variable]
[build] SDL_Thread* transfer_thread = SDL_CreateThread(transferThreadFunc, "FB TransferThread", (void*)NULL);
[build] ^~~~~~~~~~~~~~~
[build] [176/177] Building CXX object CMakeFiles/TouchGFX.dir/simulator/main.cpp.obj
[build] ninja: build stopped: subcommand failed.

 

 versions are:

  • cmake version 3.29.3
  • ninja version 1.12.1
  • gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0
Best answer by EmbDev

Sure, its just two steps:

  1. Add the TouchGFX simulator compiler to the PATH
  2. Use the generated makefile

This should be in the tasks.json:

{
 "type": "shell",
 "label": "BuildSimulator",
 "command": "mingw32-make",
 "args": [
 "-f",
 "simulator\\gcc\\Makefile",
 "-j8"
 ],
 "options": {
 "cwd": "${workspaceFolder}\\TouchGFX",
 "env": {
 "PATH": "C:/TouchGFX/4.23.0/env/MinGW/bin;C:/TouchGFX/4.23.0/env/MinGW/msys/1.0/Ruby30-x64/bin;C:/TouchGFX/4.23.0/env/MinGW/msys/1.0/bin;C:/TouchGFX/4.23.0/env/MinGW/msys/1.0/gnu-arm-gcc/bin"
 }
 },
 "problemMatcher": "$gcc",
}

 

3 replies

EmbDev
Senior
May 28, 2024

In my setup I only build for the target using CMake. When I want to run / debug the stimulator I just use the Makefile that is generated by the Designer (simulator/gcc/Makefile). Maybe you can also check the differences between the Makefile and your CMakeLists.txt.

nico23Author
Senior III
May 28, 2024

Could you please go a bit more in deep on how you do the  run / debug of the simulator with the Makefile?

GaetanGodart
Technical Moderator
May 28, 2024

Hello @nico23 ,

 

I cannot help you with that, but @Aquamarine is also trying to compile TouchGFX projects on VSCode.

 

Regards,

nico23Author
Senior III
May 28, 2024

Thanks, I'll look into it

I was following this tutorial/project built by one of your employees but it seems outdated and it generates exactly my error 

https://github.com/MaJerle/touchgfx-cmake-vscode-stm32-simulator

 

GaetanGodart
Technical Moderator
May 29, 2024

Yes this project seems to be 2 years old, things have changed since then.

I think it can still be a good starting point but it is only for simulator.

Aquamarine
Associate II
May 29, 2024

I'm trying to build TouchGFX with STM32 using VS Code and is able to archive build pass using https://github.com/MaJerle/touchgfx-cmake-vscode-stm32-simulator , However, I never tried building standalone TouchGFX project nor simulator.

I encountered similar problem during my set up, in this case, I would try to search the definition of atexit and check if it's corresponding source file was there or was in the build list.

This is my post if you think it might be useful: https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/how-to-set-up-touchgfx-for-stm32cubemx-generated-cmake-project/td-p/678889

nico23Author
Senior III
May 29, 2024

Thanks!

Yes, my goal was to build and debug the simulator via VSCode.


@Aquamarine wrote:

I encountered similar problem during my set up, in this case, I would try to search the definition of atexit and check if it's corresponding source file was there or was in the build list.


I'll try to have a look at the MakeList file, maybe is missing something

EmbDev
Senior
May 30, 2024

The atexit method is not part of the TouchGFX project, but a system include which should be part of your compiler.
Will share my non-CMake approach later here, when I have some time.