Installing GCC for openEuler
Perform the following steps to install GCC for openEuler as the root user.
- Obtain the GCC for openEuler software package and upload it to the target server.
- Set the installation directory.
- Create a GCC for openEuler installation directory, for example, /opt/aarch64/compiler.
1mkdir -p /opt/aarch64/compiler
- Copy the GCC for openEuler package to the installation directory.
1cp -rf gcc-12.3.1-2025.12-aarch64-linux.tar.gz /opt/aarch64/compiler
- Create a GCC for openEuler installation directory, for example, /opt/aarch64/compiler.
- Go to the installation directory and run the following command to decompress the software package:
1tar -xf gcc-12.3.1-2025.12-aarch64-linux.tar.gz
After decompression, the gcc-12.3.1-2025.12-aarch64-linux directory is displayed.
- Configure environment variables by either modifying the /etc/profile file or using the environment-modules tool (without modifying the /etc/profile file) to manage environment variables.
- Method 1: Modifying the /etc/profile file
- Add the following content to the end of the /etc/profile file:
1 2 3
export PATH=/opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/bin:$PATH export INCLUDE=/opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/include:$INCLUDE export LD_LIBRARY_PATH=/opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/lib64:$LD_LIBRARY_PATH
- Run the following command for the environment variables to take effect. After the server is reconnected, you do not need to run the following command again because the system automatically loads the configuration.
1source /etc/profile
- If the installation directory is different, change it to the actual directory.
- Ensure that the installation path is placed before the environment variable; otherwise, GCC for openEuler cannot be loaded, for example:
export PATH=/opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/bin:$PATH
- If you need to use non-GCC fixed components such as create_gcov, you can use rpath to automatically load the corresponding dynamic library. The related library files are stored in /opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/lib64_public.
- Add the following content to the end of the /etc/profile file:
- Method 2: Using the environment-modules tool to manage environment variables
- Create the GCC_modulefiles configuration file as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#%Module1.0##################################################################### ### ### modules modulefile ### set version 12.3.1 setenv GCC_DIR /opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux prepend-path PATH /opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/bin prepend-path INCLUDE /opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/include prepend-path LD_LIBRARY_PATH /opt/aarch64/compiler/gcc-12.3.1-2025.12-aarch64-linux/lib64 prepend-path MODULEPATH /opt/aarch64/moduledeps/gcc-12.3.1-2025.12-aarch64-linux ### family "compiler"
- To load the GCC for openEuler environment variables, run the following module commands:
1 2
module use path-of-GCC-configuration-files // path-of-GCC-configuration-files is the parent directory of GCC_modulefiles. module load GCC_modulefiles
- Create the GCC_modulefiles configuration file as follows:
- Method 1: Modifying the /etc/profile file
- After configuring and loading the GCC for openEuler environment variables, run the following command to verify the GCC for openEuler version:
1gcc -vIf the command output contains the version information of GCC for openEuler, GCC for openEuler has been successfully installed. Example:
1gcc version 12.3.1 (gcc for openEuler 3.0.5)
In the command output, content in the parentheses () indicates the version number of the current software package.
Parent topic: Installing and Using GCC for openEuler