cancel
Showing results for 
Search instead for 
Did you mean: 

VSCode extension failing to compile project after STM32CubeIDE update

SidPrice
Associate III

I just switched back to a different client project, one that is built in the STM32 VSCode extension. This was after working on a different project with STM32CubeIDE and updating it to the latest version (1.16.1).

Unfortunately, when I try to compile the VSCode-based project, it does not compile. The build task starts up but then reports the discovered compiler cannot build a simple test program.

 

Here is the contents of the terminal window:

 

Executing task: Build 

build task started....
C:\ST\STM32CubeCLT_1.15.0\CMake\bin\cmake.EXE --build D:/DataRoot/Projects/Equla/_Vert2-Firmware/STM32/Vert2-STM32/build/debug/build --
[0/1] Re-running CMake...
-- Found multiple STM32CubeIDE installations. Using "C:/ST/STM32CubeIDE_1.11.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256/tools/bin".
-- The C compiler identification is GNU 12.3.1
-- The CXX compiler identification is GNU 12.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/ST/STM32CubeIDE_1.11.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256/tools/bin/arm-none-eabi-gcc.exe
-- Check for working C compiler: C:/ST/STM32CubeIDE_1.11.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256/tools/bin/arm-none-eabi-gcc.exe - broken
CMake Error at C:/ST/STM32CubeCLT_1.15.0/CMake/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "C:/ST/STM32CubeIDE_1.11.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256/tools/bin/arm-none-eabi-gcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'D:/DataRoot/Projects/Equla/_Vert2-Firmware/STM32/Vert2-STM32/build/debug/build/CMakeFiles/CMakeScratch/TryCompile-ihvrsw'
    
    Run Build Command(s): C:/msys64/ucrt64/bin/ninja.exe -v cmTC_0427c
    [1/2] C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256\tools\bin\arm-none-eabi-gcc.exe -fdata-sections -ffunction-sections --specs=nano.specs -Wl,--gc-sections    -o CMakeFiles/cmTC_0427c.dir/testCCompiler.c.obj -c D:/DataRoot/Projects/Equla/_Vert2-Firmware/STM32/Vert2-STM32/build/debug/build/CMakeFiles/CMakeScratch/TryCompile-ihvrsw/testCCompiler.c
    [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && C:\ST\STM32CubeCLT_1.15.0\CMake\bin\cmake.exe -E rm -f libcmTC_0427c.a && C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235\tools\bin\arm-none-eabi-ar.exe qc libcmTC_0427c.a  CMakeFiles/cmTC_0427c.dir/testCCompiler.c.obj && C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235\tools\bin\arm-none-eabi-ranlib.exe libcmTC_0427c.a && cd ."
    FAILED: libcmTC_0427c.a 
    C:\WINDOWS\system32\cmd.exe /C "cd . && C:\ST\STM32CubeCLT_1.15.0\CMake\bin\cmake.exe -E rm -f libcmTC_0427c.a && C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235\tools\bin\arm-none-eabi-ar.exe qc libcmTC_0427c.a  CMakeFiles/cmTC_0427c.dir/testCCompiler.c.obj && C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235\tools\bin\arm-none-eabi-ranlib.exe libcmTC_0427c.a && cd ."
    The system cannot find the path specified.
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


-- Configuring incomplete, errors occurred!
ninja: error: rebuilding 'build.ninja': subcommand failed
FAILED: build.ninja 
C:\ST\STM32CubeCLT_1.15.0\CMake\bin\cmake.exe --regenerate-during-build -SD:\DataRoot\Projects\Equla\_Vert2-Firmware\STM32\Vert2-STM32 -BD:\DataRoot\Projects\Equla\_Vert2-Firmware\STM32\Vert2-STM32\build\debug\build
build finished with error(s).

 *  The terminal process terminated with exit code: 1. 

 

Sid

 

 

1 REPLY 1
Nawres GHARBI
ST Employee

It looks like the issue is related to the compiler configuration in your VSCode project. The error message indicates that the compiler cannot compile a simple test program, which usually points to a misconfiguration or an incorrect path to the compiler tools.

Here are some steps to troubleshoot and resolve the issue:

1. Verify Compiler Path

Ensure that the path to the compiler tools is correctly set in your VSCode project settings. It seems like the project is trying to use a specific version of the GNU ARM toolchain from the STM32CubeIDE installation. Verify that the path is correct and that the tools are accessible.

2. Update CMake Configuration

Ensure that your CMake configuration is correctly set up to use the right compiler. You might need to specify the path to the compiler explicitly in your CMakeLists.txt or in the CMake configuration files.

3. Check Environment Variables

Ensure that the necessary environment variables are set correctly. You might need to add the path to the GNU ARM toolchain to your system's PATH environment variable.

4. Clean and Rebuild

Try cleaning the build directory and rebuilding the project from scratch. Sometimes, stale build files can cause issues.

5. Check for Multiple Toolchain Versions

The error message indicates that multiple STM32CubeIDE installations were found. Ensure that the correct version is being used and that there are no conflicts between different versions of the toolchain.

Example of Setting Compiler Path in CMakeLists.txt

You can explicitly set the compiler path in your CMakeLists.txt file:

 
cmake
 
set(CMAKE_C_COMPILER "C:/path/to/arm-none-eabi-gcc.exe")
set(CMAKE_CXX_COMPILER "C:/path/to/arm-none-eabi-g++.exe")

Example of Setting Environment Variables

Ensure that the environment variables are set correctly. You can add the following to your .vscode/settings.json file:

 

json

 
{
    "cmake.environment": {
        "PATH": "C:/path/to/gnu-tools-for-stm32/bin;${env:PATH}"
    }
}

Example of Cleaning and Rebuilding

You can clean the build directory and rebuild the project by running the following commands in the terminal:

 

sh

 
rm -rf build
mkdir build
cd build
cmake ..
cmake --build .

Example of Checking and Setting PATH Environment Variable

Ensure that the path to the GNU ARM toolchain is included in your system's PATH environment variable. You can do this by adding the following line to your .bashrc, .zshrc, or .profile file (depending on your shell):

 
sh
 
export PATH="/path/to/gnu-tools-for-stm32/bin:$PATH"

Summary

  • Verify the compiler path in your VSCode settings.
  • Update the CMake configuration to explicitly set the compiler path.
  • Ensure the necessary environment variables are set correctly.
  • Clean and rebuild the project.
  • Check for multiple toolchain versions and ensure the correct one is being used.

By following these steps, you should be able to resolve the issue and successfully compile your VSCode-based STM32 project. If the problem persists, please provide more details about your project configuration and any additional error messages.