How to Use GCC Compiler in Keil MDK

Follow+Star Public Account, don’t miss exciting content
How to Use GCC Compiler in Keil MDK
Author | strongerHuang
WeChat Public Account | strongerHuang
A netizen asked: Is the Keil compilation speed a bit slow, does it support GCC compilation?
In fact, the compilation speed of Keil MDK using AC6 is relatively much faster. If you find AC5 slow, you might as well try AC6.
Here, at the request of netizens, I will share how to use the GCC compiler toolchain in Keil MDK.

About GCC

GCC originally stands for “GNU C Compiler”, it is part of the GNU Compiler Collection. GCC is a powerful, high-performance multi-platform compiler released by GNU, and is one of GNU’s representative works.
Website:
https://gcc.gnu.org
Early GCC mainly targeted the C language, but with the development of programming, it now supports not only C but also many other languages, including C++, Ada, Objective-C, Fortran, and Java.
Therefore, the meaning of GCC has been redefined as “GNU Compiler Collection“, which means “GNU Compiler Suite”.
GCC is favored by many software developers for an important reason: it is free. You will find that many open-source IDEs basically integrate the GCC compiler, such as STM32CubeIDE, RT-Thread Studio, etc.
For more information about GCC, you can refer to my previous article Why Is GCC So Powerful?

Download GCC Toolchain

The GCC toolchain used here is actually the “GNU Arm Embedded Toolchain“, which is a set of tools officially recommended by ARM, mainly targeting 32-bit Arm Cortex-M, Cortex-R, and Cortex-A series processors as a toolchain.
GNU Arm includes the GNU Compiler (GCC), which can be obtained for free from Arm and is used for embedded software development on Windows, Linux, and Mac OS X operating systems.
Download Link:
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads
(The public account does not support external links, please copy the link to open in a browser)
Go to the webpage and choose the appropriate version to download based on your system:
How to Use GCC Compiler in Keil MDK
Of course, we choose the Windows version exe file or compressed file. (Because Keil only supports the Windows version).
In fact, you can find branches on the GCC trunk:
https://gcc.gnu.org/git/gcc.git

Install GCC Toolchain

Method 1: Install exe file
Installing the exe file on Windows is something every programmer can install; just follow the prompts and basically hit “next” all the way through.
How to Use GCC Compiler in Keil MDK
How to Use GCC Compiler in Keil MDK
How to Use GCC Compiler in Keil MDK
How to Use GCC Compiler in Keil MDK
How to Use GCC Compiler in Keil MDK
Method 2: Directly extract the zip file
If you downloaded the zip file, simply extract it to the specified directory.
If you performed the first method of exe installation, you will find that the installed files are the same as the files extracted here.
How to Use GCC Compiler in Keil MDK

Configure GCC Toolchain in Keil

The configuration method here is similar to the method in my previous article “Step-by-Step Guide to Upgrading the ARM Compiler in Keil MDK” in Chapter 3 [Configuring the Compiler in Keil].
Open Project Management and go to the “Folders/Extensions” option
You can enter through the menu: Project -> Manage -> Project items.
You can also enter through the toolbar project management shortcut icon:
How to Use GCC Compiler in Keil MDK
The method of switching the compiler tool configuration here is relatively simple, and you can use it as usual.

Additional Notes

Switching compilers will cause changes to the project configuration options, such as:
How to Use GCC Compiler in Keil MDK
Changes in configuration options are minor issues because different compilers may cause code incompatibility, for example, if you directly compile code targeting the Arm compiler, it will definitely cause problems.
There are many details here, and I will describe the content of switching compilers and code migration modifications when I have time later.

———— END ————

How to Use GCC Compiler in Keil MDK

● Column “Embedded Tools”

● Column “Embedded Development”

● Column “Keil Tutorial”

● Selected Tutorials from Embedded Column

Follow the public account reply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.

How to Use GCC Compiler in Keil MDK

How to Use GCC Compiler in Keil MDK

Click “Read the Original” to see more shares.

Leave a Comment