Linux randomly deleted my file while compiling what do I do?

烂漫一生 提交于 2020-07-30 07:47:40

问题


gcc -L/root/Desktop - Wall -o prog3.c -pthread -lcopy
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.0: In function '_start': (.text+0x20): undefined reference to 'main' 
collect2: error: ld returned 1 exit status

This is my error code. prog3.c is nowhere to be found, what on earth happened is there any way to get my file back?? The bold is the command I ran and the rest is the resultant console output


回答1:


Your problem is here: -o prog3.c. gcc’s -o option is used to tell gcc which name it should give to the executable it generates. So here, you’re basically asking your compiler to replace your prog3.c source file by an executable. Sadly your code is gone...




回答2:


Little addendum of your options in such scenario:

  1. It was Git (or any other version control) repository. In such case, you can simply bring it from previous commit

  2. Your editor/IDE has some back-up system. Sometimes I need to bring back a file I've thought was needless. For such case, my favourite text editor should have create already back-up file in appropriate location (e.g. $XDG_DATA_HOME/vim/backup in my case).

If none of above, but you still have previously correctly compiled binary file

  1. You can try to decompile, but this process - even if successful - isn't lossless (e.g. code is basically spaghetti).

  2. Had you compiled with -g flag, you could possibly retrieve the code from debug info.

  3. You can at least de-assemble to Assembly code.



来源:https://stackoverflow.com/questions/47423990/linux-randomly-deleted-my-file-while-compiling-what-do-i-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!