Linux c++ linker – “ld terminated with signal 9”

The linker error “ld terminated with signal 9” is caused by low amount of memory for link process. There are two ways how to fix it.

  • First way is increase computer / virtual machine memory.
  • Second way is by increasing swap file size.

How to increase swap file size

#create new swap file 512x1M size filled with zeros
sudo dd if=/dev/zero of=/extraswap bs=1M count=512

#setup file as a swap file
sudo mkswap /extraswap

#enable created swapfile
sudo swapon /extraswap

If you want to use this swap file also after your computer reboot, you have to do also following steps:

#edit fstab
sudo nano /etc/fstab

#add following line to /etc/fstab
/extraswap           swap                    swap    defaults        0 0

[/sourcecode]

Additional swap-file commands

Here is a list of additional commands which can be useful when working with swap file


#show memory information in KB
free -k

#show existing swap file sizes in KB
swapon -s

External articles about this subject:

http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/

https://www.linux.com/learn/tutorials/442430-increase-your-available-swap-space-with-a-swap-file

http://www.saicharan.in/blog/2009/06/30/ld-terminated-with-signal-9/

2 comments

Leave a Reply to Arky Cancel reply

Your email address will not be published. Required fields are marked *