File not recognized: File truncated GCC error

Solution 1:

Just remove the object file.

This error most likely appeared after the previous build was interrupted and object file was not generated completely.

Solution 2:

Just as an info if someone comes around here.

Another problem (with the same error) could be, that you are using ccache for faster compilation. In this case, the corrupt *.o file is there as well. So for that reason you have to clean the cache with

ccache -C (note the upper case C!)

Wasted me hours the first time ;-)

Solution 3:

I think

g++  -o "hello"  ./src/hello.o  
should be ./src/hello.(c | cpp | cc depending on your language type)