Rate This Document
Findability
Accuracy
Completeness
Readability

Configuring the Compilation Environment

Installing Dependencies

  1. Mount the OS image.
    1
    mount YOUR_OS.iso /media -o loop
    

    Replace YOUR_OS.iso with the actual iso package name.

  2. Back up the repo file and clear the /etc/yum.repos.d/ directory.
    1
    2
     /etc/yum.repos.d-bakcp -r /etc/yum.repos.d
    rm /etc/yum.repos.d/*
    

    Ensure that all repo files have been backed up. Enter y on the rm deletion page to delete the files.

  3. Configure a local Yum source.
    1. Open the /etc/yum.repos.d/Local.repo file.
      1
      vi /etc/yum.repos.d/Local.repo
      
    2. Press i to enter the insert mode and add the following content to the file:
      1
      2
      3
      4
      5
      [Local]
      name=Local
      baseurl=file:///media/
      enabled=1
      gpgcheck=0
      
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Make the Yum source configuration take effect.
    1
    2
    yum clean all
    yum makecache
    
  5. Use the Yum source to install GCC related software.
    1
    yum -y install gcc gcc-c++ gcc-gfortran.aarch64 libgcc.aarch64 make cmake libtool autoconf automake ant wget git vim
    

Modifying GCC (to Solve the -fsigned-char Problem)

  1. Search for the directory where the GCC is located. Generally, the directory is /usr/bin/gcc.
    1
    command -v gcc
    
  2. Change the name of the original GCC file, for example, to gcc-impl.
    1
    mv /usr/bin/gcc /usr/bin/gcc-impl
    
  3. Create a GCC file.
    1
    vi /usr/bin/gcc
    
  4. Press i to enter the insert mode and add the following content to the file:
    1
    2
    #! /bin/sh
    /usr/bin/gcc-impl -fsigned-char "$@"
    
  5. Press Esc, type :wq!, and press Enter to save the file and exit.
  6. Add the execute permission for the GCC file.
    1
    chmod +x /usr/bin/gcc
    
  7. Check whether the GCC is available.
    1
    gcc --version
    
    • CentOS: The installation is successful if information similar to the following is displayed:

    • openEuler: The installation is successful if information similar to the following is displayed:

Modifying G++ (to Solve the -fsigned-char Problem)

  1. Search for the directory where G++ is located. Generally, the directory is /usr/bin/g++.
    1
    command -v g++
    
  2. Change the original G++ file name, for example, to g++-impl.
    1
    mv /usr/bin/g++ /usr/bin/g++-impl
    
  3. Create a G++ file.
    1
    vi /usr/bin/g++
    
  4. Press i to enter the insert mode and add the following content to the file:
    1
    2
    #! /bin/sh
    /usr/bin/g++-impl -fsigned-char "$@"
    
  5. Press Esc, type :wq!, and press Enter to save the file and exit.
  6. Add the execute permission for the G++ file.
    1
    chmod +x /usr/bin/g++
    
  7. Check whether the G++ file is available.
    1
    g++ --version
    
    • CentOS: The installation is successful if information similar to the following is displayed:

    • openEuler: The installation is successful if information similar to the following is displayed:

Installing OpenJDK

  1. Download and decompress the installation package to a directory (for example, /opt/tools/installed).
    1
    2
    3
    4
    wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u252-b09/OpenJDK8U-jdk_aarch64_linux_hotspot_8u252b09.tar.gz
    tar -zxf OpenJDK8U-jdk_aarch64_linux_hotspot_8u252b09.tar.gz
    mkdir -p /opt/tools/installed/
    mv jdk8u252-b09 /opt/tools/installed/
    
  2. Configure Java environment variables.
    1. Edit the /etc/profile file.
      1
      vi /etc/profile
      
    2. Press i to enter the insert mode and add the following content to the end of the file:
      1
      2
      export JAVA_HOME=/opt/tools/installed/jdk8u252-b09
      export PATH=$JAVA_HOME/bin:$PATH
      
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  3. Make the environment variables take effect.
    1
    source /etc/profile
    
  4. Check whether OpenJDK is successfully installed.
    1
    java -version
    

    If the OpenJDK version is displayed in the command output, the installation is successful.

    1
    2
    3
    openjdk version "1.8.0_252"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode)
    

Installing Maven

  1. Download and install the installation package to a directory (for example, /opt/tools/installed).
    1
    2
    3
    wget https://archive.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
    tar -zxf apache-maven-3.5.4-bin.tar.gz
    mv apache-maven-3.5.4 /opt/tools/installed/
    
  2. Modify the Maven environment variables.
    1. Edit the /etc/profile file.
      1
      vi /etc/profile
      
    2. Press i to enter the insert mode and add the following content to the end of the file:
      1
      2
      export MAVEN_HOME=/opt/tools/installed/apache-maven-3.5.4
      export PATH=$MAVEN_HOME/bin:$PATH
      
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  3. Make the environment variables take effect.
    1
    source /etc/profile
    
  4. Check whether Maven is successfully installed.
    1
    mvn -v
    

    The installation is successful if information similar to the following is displayed:

    1
    2
    3
    4
    5
    Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
    Maven home: /opt/tools/installed/apache-maven-3.5.4
    Java version: 1.8.0_252, vendor: AdoptOpenJDK, runtime: /opt/tools/installed/jdk8u252-b09/jre
    Default locale: en_US, platform encoding: UTF-8
    0S name: "linux", version: "4.14.0-115.el7a.0.1.aarch64", arch: "aarch64", family: "unix"
    
  5. Modify the local repository path and remote repository in the Maven configuration file.
    1. Open the configuration file.
      vi /opt/tools/installed/apache-maven-3.5.4/conf/settings.xml

      The default local repository directory is ~/.m2/. If you want to change the directory to a specified one, modify the localRepository tag. You do not need to modify this parameter unless otherwise specified.

    2. Press i to enter the insert mode. Add the following content to the <mirrors> tag to configure the remote repository (change the repository to the Maven repository that you have built. If the Maven repository does not exist, configure it based on the following example):
      1
      2
      3
      4
      5
      6
      <mirror>
        <id>huaweimaven</id>
        <name>huawei maven</name>
        <url>https://mirrors.huaweicloud.com/repository/maven/</url>
        <mirrorOf>central</mirrorOf>
      </mirror>
      
    3. Optional: If the compilation environment cannot access the Internet, add the following proxy configuration to settings.xml:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      <proxies>
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>Username</username>
          <password>Password</password>
          <host>Proxy server URL</host>
          <port>Proxy server port</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
      </proxies>
      
    4. Press Esc, type :wq!, and press Enter to save the file and exit.