我要评分
获取效率
正确性
完整性
易理解

Installing GCC for openEuler

Perform the following steps to install GCC for openEuler as the root user.

  1. Obtain the GCC for openEuler software package and upload it to the target server.
  2. Set the installation directory.
    1. Create a GCC for openEuler installation directory, for example, /opt/aarch64/compiler.
      1
      mkdir -p /opt/aarch64/compiler
      
    2. Copy the GCC for openEuler package to the installation directory.
      1
      cp -rf gcc-12.3.1-2025.12-aarch64-linux.tar.gz /opt/aarch64/compiler
      
  3. Go to the installation directory and run the following command to decompress the software package:
    1
    tar -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.

  4. 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
      1. 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
        
      2. 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.
        1
        source /etc/profile
        
      1. If the installation directory is different, change it to the actual directory.
      2. 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

      3. 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.
    • Method 2: Using the environment-modules tool to manage environment variables
      1. 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"
        
      2. 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
        
  5. After configuring and loading the GCC for openEuler environment variables, run the following command to verify the GCC for openEuler version:
    1
    gcc -v
    

    If the command output contains the version information of GCC for openEuler, GCC for openEuler has been successfully installed. Example:

    1
    gcc 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.