Error loading shared library. Invalid ELF header

I am trying to compile a simple C program but I’m getting the following error:

user~$ gcc HelloWorldSleep.c -o HelloWorldSleep

/usr/lib/gcc/arm-linux-gnueabihf/4.9/cc1: error while loading shared libraries: /usr/lib/arm-linux-gnueabihf/ invalid ELF header

Does this mean I need to upgrade gcc or one of its libraries?

This sounds like a platform incompatibility issue. e.g. something you’re trying to use it not meant for the ARM ABI. In other words, perhaps either your executable, or shared library is for x86 or x86-64.