linux – make -j 8 g++: internal compiler error: Killed (program cc1plus)

linux – make -j 8 g++: internal compiler error: Killed (program cc1plus)

Try running (just after the failure) dmesg.

n

Do you see a line like this?

n

Out of memory: Kill process 23747 (cc1plus) score 15 or sacrifice childnKilled process 23747, UID 2243, (cc1plus) total-vm:214456kB, anon-rss:178936kB, file-rss:5908kBn

n

Most likely that is your problem. Running make -j 8 runs lots of process which use more memory. The problem above occurs when your system runs out of memory. In this case rather than the whole system falling over, the operating systems runs a process to score each process on the system. The one that scores the highest gets killed by the operating system to free up memory. If the process that is killed is cc1plus, gcc (perhaps incorrectly) interprets this as the process crashing and hence assumes that it must be a compiler bug. But it isnt really, the problem is the OS killed cc1plus, rather than it crashed.

n

If this is the case, you are running out of memory. So run perhaps make -j 4 instead. This will mean fewer parallel jobs and will mean the compilation will take longer but hopefully will not exhaust your system memory.

(Might be a memory issue)

n

For anybody still struggling with this (over 2 years after the question was asked), theres this trick on CryptoCurrencyTalk that seems to make it work.

n

For convenience Im pasting it here:

n

Run these (adjust bs= and count= to the amount of swap you want)

n

    n

  • sudo dd if=/dev/zero of=/swapfile bs=64M count=16
  • n

  • sudo mkswap /swapfile
  • n

  • sudo swapon /swapfile
  • n

n

That should let you compile your code. But make sure you then revert the swapon after compilation, with these:

n

    n

  • sudo swapoff /swapfile
  • n

  • sudo rm /swapfile
  • n

linux – make -j 8 g++: internal compiler error: Killed (program cc1plus)

check if your CentOS installation already has swap enabled by typing:

n

sudo swapon --shown

n

If the output is empty, it means that your system does not have swap space enabled.

n

Create a swap file

n

1.create a file which will be used as a swap space. bs is the size of one block. count is num of blocks. it will get 1024K * 1M = 1G space.

n

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

n

2.Ensure that only the root user can read and write the swap file:

n

sudo chmod 600 /swapfile

n

3.set up a Linux swap area on the file

n

sudo mkswap /swapfilen

n

4.activate the swap

n

sudo swapon /swapfilen

n

5.sudo swapon –show or sudo free -h you will see the swap space.

Leave a Reply

Your email address will not be published.