C++: fatal error: Killed signal terminated program cc1plus

created at 06-19-2022 views: 353

1.Problem description

When compiling C++ in the Linux system, the following error occurs, causing the compilation to abort:

C++: fatal error: Killed signal terminated program cc1plus
compilation terminated.

2.Solution - swap partition

After checking the relevant information, it is believed that the virtual machine memory is insufficient. This problem was solved by creating a swap partition, and the compilation was successful. The following summarizes the creation and activation of swap partitions:

Create partition path

sudo mkdir -p /var/cache/swap/

Set the size of the partition bs=64M is the block size, count=64 is the number of blocks, so the swap space size is bs*count=4096MB=4GB

sudo dd if=/dev/zero of=/var/cache/swap/swap0 bs=64M count=64

Set the directory permissions

sudo chmod 0600 /var/cache/swap/swap0

Create a SWAP file

sudo mkswap /var/cache/swap/swap0

Activate SWAP file

sudo swapon /var/cache/swap/swap0

Check whether the SWAP information is correct

sudo swapon -s

The path of the swap0 file is under /var/cache/swap/. After compiling, if you don't want the swap partition, you can delete it.

Command to delete swap partition:

sudo swapoff /var/cache/swap/swap0
sudo rm /var/cache/swap/swap0

Free space command:

sudo swapoff -a
created at:06-19-2022
edited at: 06-19-2022: