g++: internal compiler error: Killed (program cc1plus)

make compile time, prompt g++: internal compiler error: directed at program cc1plus , with the following detailed error message:

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
Error 4

The is shown in figure 1:

figure 1 compiler error message

Google, the unified answer is because memory is not enough , free looked at the system memory usage, it was really occupied. Since the device is the company’s uniform compilation platform (used by several colleagues), this is not surprising. As shown in figure 2:

figure 2 free – h details

can be solved by the following solution:
(1) sudo dd if=/dev/zero of=/swapfile bs=64M count=16 (the size of count is the size of the increased swap space, 64M is the block size, So the space size is bs*count=1024MB)
(2)sudo mkswap /swapfile (format the space just now as swap format) (3)sudo swapon /swapfile (use the swap space just created)


Read More: