I am writing code for a project on a raspberry pi via ssh and using g++ to compile my files. My header files are contained in a directory called headers and my codefiles in a directory called codefiles. To compile, I run this code.
g++ -I headers -o test codefiles/*.cpp
It has been working fine since I started the project, until today when it gave me this error:
/usr/bin/ld: /tmp/ccZXxmDc.o: in function `main': main.cpp:(.text+0x48): undefined reference to `File::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' /usr/bin/ld: main.cpp:(.text+0x94): undefined reference to `File::saveFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' collect2: error: ld returned 1 exit status
I went to check the file.cpp
file and it was completely gone from my directory. Why is this happening?
Edit for a little more context: this happened multiple times, giving the same error. The first time it happened was a smaller code file that I rewrote and when tried to compile it got rid of the file.cpp file.