Issue
I'm trying to compile one txt file using gcc in Ubuntu.
Procedure it like this.
I'm making test.c.txt file using
vi test.c.txt
Using gcc -o,
gcc -o Q1.out test.c.txt
Actually, when I practiced this code yesterday, I worked. but today, it doesn't work.
error message is like this.
file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
How can I compile this file?
Solution
.txt
are text files, you have to tell gcc what file is that.
- If that file is in C programming language, you can tell gcc that with
-x
option likegcc -xc -o Q1.out test.c.txt
. - Or you can rename the file from
.txt
to.c
and gcc will "guess" that the file is written in C language when the filename ends with.c
.
Answered By - KamilCuk