Follow+Star Public Account, don’t miss exciting content
Author | strongerHuang
WeChat Public Account | strongerHuang
Recently, I have received some questions from readers:
Can Keil use GCC to compile code?
Can Keil use other compilers?
When you use other GUN toolchains for compilation, you may encounter errors like the following:
--- Error: can't execute 'as'--- Error: can't execute 'gcc'
There are many different variants of the GCC compiler for ARM chips. Currently, Keil MDK still supports the GCC compiler. Below, I will explain how to use the GCC compiler toolchain in Keil MDK.
GCC originally stands for “GNU C Compiler”, which is part of the GNU Compiler Collection. GCC is a powerful, high-performance, multi-platform compiler released by GNU, and it is one of the representative works of GNU.
As of now (2020-11), GCC has been updated to version V10.2.
In the early days, GCC primarily targeted the C language. 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, GCC’s meaning has been redefined as “GNU Compiler Collection“, which refers to the “GUN Compiler Suite”.
One important reason why GCC is favored by many software developers is that 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?
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.
“GNU Arm“ includes the GNU Compiler (GCC), which can be obtained for free from Arm, used for embedded software development on Windows, Linux, and Mac OS X operating systems.
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 your browser to open)
Enter the webpage and select the appropriate version for your system to download:

Of course, we choose the Windows version exe file or compressed file here. (Because Keil only supports Windows version).
In fact, you can find branches on the gcc trunk:
https://gcc.gnu.org/git/gcc.git
Method 1: Install exe file
When installing the exe file on Windows, it is a program that every programmer can install. Just follow the prompts, and basically, you can go through by clicking “next” all the way.





Method 2: Directly unzip zip file
If you downloaded a zip file, simply unzip it to the designated directory.
If you have done the first method of exe installation, you will find that the installed files are the same as the files unzipped here.

Configure GCC Toolchain in Keil
The configuration method here is similar to the method in my previous article “Step-by-Step Guide to Upgrade Keil MDK’s ARM Compiler” in Chapter 3 [Configuring Compiler in Keil].
Open Project Management, go to the “Folders/Extensions” tab
You can enter through the menu: Project -> Manage -> Project items.
You can also enter through the toolbar project management shortcut icon:

Switching the configuration of the compiler tool is relatively simple, and you can use it normally as before.
Switching compilers may cause changes in project configuration options, such as:

Changes in configuration options are minor issues because the code incompatibility among different compilers is the major problem. For example, if you directly compile code targeted for the Arm compiler, there will definitely be issues.
There are many details here, and I will find time later to describe the content of switching compilers and code migration modifications.
———— END ————

●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.
Click “Read Original” to see more shares.