# STM32CubeIDE on Windows

{% hint style="info" %}
Though the methods in this page work both on Linux and Windows, on Linux you may rely on integrated Bear process to generate the compilation database, and therefore use your usual build process flawlessly.
{% endhint %}

STM32CubeIDE projects are generating Makefiles that can then be used using the strategy defined in [Makefiles compatibility section](/documentation/ressources/compatibility-guide/makefiles-on-windows.md), with a few extra configuration steps.

STM32CubeIDE projects works the following way to compile a project:

* Generation of Makefiles
* Instrumentation of the PATH variable to make use of the right tools (make command, compiler, linker, etc)
* Execution of the `make` command.

This method conflicts with the method used by `below-make-intercept` to generate a compilation database. Because of this, the `below-make-intercept` must be run after PATH variable instrumentation, which must be replicated.

To do that, the user must:

* Generate the Makefiles (using STM32CubeIDE directly, by running at least one build).
* Find the paths used by STM32CubeIDE for:
  * The `make` command
  * The compiler invokations
* Inject these paths
* Call `below-make-intercept` directly on the `make` command.

This section details how to do that, taking the STM32CubeIDE example project 53L1A2\_MultiSensorRanging, targeting NUCLEO-F401RE (Cortex-M4), on Windows.

The project is possible to setup quickly by clicking on ***File -> New -> STM32 Project***.

There, on tab ***Example selector***, select project ***53L1A2\_MultiSensorRanging*** for NUCLEO-F401RE.

<figure><img src="/files/AOIAahpaUiCqzokEenmG" alt=""><figcaption><p>Project selection in STM32CubeIDE</p></figcaption></figure>

On the newly imported project, set ***Release*** target active.

<figure><img src="/files/WXxt7xHs9JoA4sqhzYEv" alt=""><figcaption><p>Set Release target active</p></figcaption></figure>

Then, build the project. This will generate the build files, hence the Makefiles. Then, clean the project to be in a clean state.

Let's now build the project from a terminal instead of STM32CubeIDE. **Open Release directory** in the system explorer, and then **open a PowerShell terminal** from Release directory.

<figure><img src="/files/1wUgDV6x92kkzK4DYYxm" alt=""><figcaption><p>Open Release folder</p></figcaption></figure>

<figure><img src="/files/Cwzd554aTnGYIFYWxvxh" alt=""><figcaption><p>Open a terminal </p></figcaption></figure>

Now, the objective is to make the command `make all` work in this terminal. To do that, we must setup the environment so `make` command and `arm-none-eabi-gcc` are recognized.

To find the required environment, in STM32CubeIDE, go to **project properties**, in **C/C++ Build -> Environment** and check the content of the PATH variable, so you can identify where the commands are. In general, both are in different directories. On a classical installation of STM32CubeIDE, the directory containing the `make` command is something like:

```
C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_2.2.0.202409170845\tools\bin
```

The directory containing the `arm-none-eabi-gcc` command is something like:

```
C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344\tools\bin
```

In the PowerShell terminal, we may now inject these paths and build the project.

{% code overflow="wrap" lineNumbers="true" %}

```powershell
$env:PATH="C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_2.2.0.202409170845\tools\bin;C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344\tools\bin;$env:PATH"
make all
```

{% endcode %}

The project compiles! Now, from the same terminal, we can generate a compilation database by using `below-make-intercept` tool, as descripted in [the previous section](broken://pages/TlZQjfD5frWIOQKStRNw).

The best thing to do here is to create a PowerShell script with the following content:

{% code title="generate-cdb.ps1" overflow="wrap" lineNumbers="true" %}

```powershell
$env:PATH="C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_2.2.0.202409170845\tools\bin;C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344\tools\bin;$env:PATH"
make clean
below-make-intercept "make all" | Out-File -Encoding ASCII -FilePath .\compile_commands.json
```

{% endcode %}

Now, calling this script directly in the ***Configure script*** in beLow will generate the required compilation database.

If you don't wish to modify your global environment, you may also create a clean and a build script.

{% code title="clean.ps1" overflow="wrap" lineNumbers="true" %}

```powershell
$env:PATH="C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_2.2.0.202409170845\tools\bin;C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344\tools\bin;$env:PATH"
make clean
```

{% endcode %}

{% code title="build.ps1" overflow="wrap" lineNumbers="true" %}

```powershell
$env:PATH="C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_2.2.0.202409170845\tools\bin;C:\ST\STM32CubeIDE_1.18.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344\tools\bin;$env:PATH"
make all
```

{% endcode %}

Therefore, the typical commands setup in beLow would be the following ones.

For ***Configure*** section, enter:

* Script content:

```powershell
.\generate-cdb.ps1
```

* Script execution path: In the target directory
* Shell: **Pwsh**

For ***Clean*** section, enter:

* Script content:

```powershell
.\clean.ps1
```

* Script execution path: In the target directory
* Shell: **Pwsh**

For ***Build*** section, enter:

* Script content:

```powershell
.\build.ps1
```

* Script execution path: In the target directory
* Shell: **Pwsh**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wedolow.com/documentation/ressources/compatibility-guide/stm32cubeide-on-windows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
