![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.45.37.png)
The explanation here is for PC where there is installed Linux, in particular UBUNTU (18.04.3 LTS).
Download STM32CubeIDE, unzip it, change the permission of the file:
st-stm32cubeide_1.1.0_4551_20191014_1140_amd64.deb_bundle.sh
In the terminal do the commands below:
sudo su
chmod +x st-stm32cubeide_1.1.0_4551_20191014_1140_amd64.deb_bundle.sh
and next install it:
./st-stm32cubeide_1.1.0_4551_20191014_1140_amd64.deb_bundle.sh
For install the compiler for Linux do the commands below:
sudo su
apt update
apt install build-essential
After the above commands on your Linux there is the GCC compiler for your PC.
Now is possible use the STM32CubeIDE also for write a C code for your PC (Host).
For more info see here.
For know the version of the installed GCC use the command below:
gcc --version
You must see an answer like below:
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Now run STM32CubeIDE an select your working directory.
When STM32CubeIDE is open, do the steps shown below.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.46.38.png)
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.47.17.png)
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.47.49.png)
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.48.46.png)
Now add the main.c file to your workspace, see below.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.49.14.png)
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.49.49.png)
Now open the main.c and insert the below code.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.50.22.png)
Compile the code, see below.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.51.04.png)
If all is correct you must see something like below.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.51.34.png)
The file:
TSTHostLinux1
is the executable Linux file.
For run this file open a terminal go in your working directory under DEBUG folder and run it:
./TSTHostLinux1
and you must see something like below.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.52.27.png)
This is useful for practice in C syntax without the necessity to use MCU or online C compiler like this.
Of course, you must see the results of your SW also directly inside the STM32CubeMX, see how to do in the below images.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.53.52.png)
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.54.31.png)
The above results are for this example.
For insert a .h file in your project do the sequence shown below.
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.55.05.png)
![](https://www.emcu-homeautomation.org/wp-content/uploads/2024/03/Screenshot-2024-03-31-20.55.39.png)