During compilation and linking of a simple program, I encountered a weird behavior of gcc
that I cannot explain.
This here works perfectly fine for me
cc -Wall -c -o obj/main.o src/main.ccc -Wall -c -o obj/foo.o src/foo.ccc -Wall -o bin/program obj/main.o obj/foo.o
However, once I ask gcc
to create and store dependency information in a separate file, the linker throws an error:
cc -MM -MP -MF deps/main.d -Wall -c -o obj/main.o src/main.ccc -MM -MP -MF deps/foo.d -Wall -c -o obj/foo.o src/foo.ccc -Wall -o bin/program obj/main.o obj/foo.o# obj/main.o: file not recognized: File truncated# collect2: error: ld returned 1 exit status
I expect gcc
to write the dependency information in the file provided with the -MF statement. In seems that the object files are somehow modified such that the linker cannot read them anymore.
Any suggestions?