cancel
Showing results for 
Search instead for 
Did you mean: 

'atexit' was not declared in this scope

nico23
Associate III

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
16 REPLIES 16

Hello @nico23 ,

 

You can debug the simulator using Visual Studio if you have it.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

yeah, I've tried that but, I would prefer to use VS Code because its multi platform support (can't use VS on Mac)

Hello @nico23 ,

 

Did you include #include <stdlib.h> in your OSWrapper.hpp/cpp?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Sorry for the delay, this is the launch.json file I use in VS Code:

 

{
    "configurations": [
        {
            "name": "Debug Simulator",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/TouchGFX/build/bin/simulator.exe",
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/TouchGFX/4.23.0/env/MinGW/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "BuildSimulator"
        }
    ],
    "version": "2.0.0"
}

 

The pre-launch-task is optional and can be removed. In my case it is a task to build the Simulator executable, which you can also do manually in the TouchGFX Designer.

Amazing, thanks a lot. I'll try it right away

Could you let me know the configuration for the preLaunchTask as well as, I would like to have everything concerning the simulatore on VS Code?

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",
}

 

Wonderful, everything works. Thank's a lot!