seteuid0's blog
Themed by Diary.
file not recognized: File truncated错误解决办法

使用rpmbuild重新编译clamav,遇到了:file not recognized: File truncated。感觉不像时程序代码问题,找到以下解决办法:

when the compilation line looks like:c++ -Dmylib\_EXPORTS -Wall -Werror -g -fPIC -I/home/user/dev/mygit/build -I/home/user/dev/mygit/src -o CMakeFiles/mylib.dir/MyCppClass.cpp.o -c /home/user/dev/mygit/src/MyCppClass.cppcomes from the fact that, as stated, the generated object (.o) file is empty (or just truncated). A quick look can also tell it:ls -l CMakeFiles/mylib.dir/Now, when the issue remains even though you re-run the compilation line, it may come from the fact that the object (.o) file is empty/truncated within the compilation cache (ccache) itself. It may happen, for instance, when the machine/server is (abruptly) re-booted while a compilation is running. Indeed, it is highly probable that your c++ command wraps the use of a compilation cache:$ type c++ c++ is hashed (/usr/lib/ccache/c++)If that is case, you can get rid of the compilation cache:rm -rf ~/.ccacheYou still have to delete the truncated files from the current generated directory:``` rm -rf CMakeFiles/mylib.dir/

验证后可以解决问题,看后才想起之前就遇到并用该方法解决了类似问题,过了好久都不记得了。 原因就是编译时会建立cache,由于编译被机器重启等事件中断,导致cache有问题,只需要把缓冲清空即可。 参考:http://fossdev.blogspot.com/2011/08/file-not-recognized-file-truncated.html