Try this. You many need to use sudo command for the swap space.
Type "dmesg",
[ 1377.575785] Out of memory: Kill process 12305 (cc1plus) score 905 or sacrifice child
[ 1377.575800] Killed process 12305 (cc1plus) total-vm:579928kB, anon-rss:546144kB, file-rss:0kB
If you see output like this, your machine does not have enough memory to compile.
You can fix this by adding more swap.
To add a 1gb swap file, in /swapfile:
sudo dd if=/dev/zero of=/swapfile bs=1024M count=1000
sudo mkswap /swapfile
sudo swapon /swapfile
After compiling
sudo swapoff /swapfile
sudo rm /swapfile
Please post any further issues.