简体   繁体   English

文件无法识别:文件截断 GCC 错误

[英]File not recognized: File truncated GCC error

I'm trying to compile a simple "Hello World" program in Linux using Eclipse, but I always get this:我正在尝试使用 Eclipse 在 Linux 中编译一个简单的“Hello World”程序,但我总是得到这个:

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?有谁知道问题是什么?

Just remove the object file.只需删除目标文件。

This error most likely appeared after the previous build was interrupted and object file was not generated completely.此错误最有可能出现在先前的构建中断并且未完全生成目标文件之后。

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.另一个问题(具有相同的错误)可能是,您正在使用ccache进行更快的编译。 In this case, the corrupt *.o file is there as well.在这种情况下,损坏的 *.o 文件也在那里。 So for that reason you have to clean the cache with因此,出于这个原因,您必须使用

ccache -C (note the upper case C!) ccache -C (注意大写 C!)

Wasted me hours the first time ;-)第一次浪费了我几个小时;-)

I think我认为

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM