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

前端 未结 2 1883
我在风中等你
我在风中等你 2021-01-23 01:25
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          


        
相关标签:
2条回答
  • 2021-01-23 01:38

    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...

    0 讨论(0)
  • 2021-01-23 01:40

    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.

    0 讨论(0)
提交回复
热议问题