Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File not recognized: File truncated GCC error

Tags:

c++

gcc

eclipse

I'm trying to compile a simple "Hello World" program in Linux using Eclipse, but I always get this:

Building target: hello
Invoking: GCC C++ Linker
g++  -o "hello"  ./src/hello.o   
./src/hello.o: file not recognized: File truncated
collect2: ld returned 1 exit status
make: *** [hello] Error 1

**** Build Finished ****

Does anyone have an idea what the problem is?

like image 601
Adrian Avatar asked Apr 19 '11 08:04

Adrian


2 Answers

Just remove the object file.

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

like image 113
Kostyantyn Ivanov Avatar answered Nov 04 '22 21:11

Kostyantyn Ivanov


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 ;-)

like image 20
Rainer Avatar answered Nov 04 '22 22:11

Rainer