I've watched tons of videos about how to use sublime text 3 I do what they say but it doesn't work. When i type "subl test.c" in terminal it opens up a a file called test.c in sublime text 3 when i use the command gcc -c test.c everything is fine too, but when I try to run the code using ./test it says bash: ./test: No such file or directory
-
3`gcc test.c` will create a `a.out`. Don't create executables called `test` – Jean-François Fabre Dec 03 '16 at 08:25
3 Answers
Bash says that there is no such file or directory because you haven't created a file called 'test'. You should specify an output filename, i.e. you should type gcc test.c -o your_out_filename
. Then you may run your program using ./your_out_filename
. Without -o
flag gcc will create a a.out
by default, so your out_filename will be a.out
.

- 1,039
- 7
- 15
You have to use the following command to create a file called test
:
gcc test.c -o test
If you don't use the -o option (gcc test.c
) your created file will be a.out
.
The option -c
of gcc only compiles your file and doesn't link it to a program which you can run. The result of the -c
option is only an object file called test.o
.
Therefore the easiest way is the one I have mentionend above (-o
option).

- 399
- 2
- 15
You have to run:
gcc -o output test.c
output
is the file you have to do ./output
in terminal for it to execute

- 476
- 7
- 19