I want to compile c program on dos prompt using tcc as well as tc without using c editor. please give the full procedure.
-
have you already written the source code? – harryovers Nov 24 '09 at 03:49
4 Answers
I would look at the TCC documentation, specifically the quick start guide, provided on the TCC web page. Assuming you have some source code already, a compilation is as simple as
tcc -o executable.exe sourcefile.c
You can also run a C file directly with the -run
option, as in
tcc -run sourcefile.c

- 59,527
- 19
- 156
- 165
-
Oh yes, those compilers had the option to compile to memory and run the executable without writing it to disk. – Alexandru Nov 24 '09 at 12:28
you can run code without using an editor by using
tcc -run -
Using argument "-" will open stdin and you can write the code within stdin and execute it on the fly.

- 139
- 8
-
I'm trying to develop an IDE based on TCC. I'd like to run TCC just as you said (```tcc -run -```), then I'm feeding source code to TCC's stdin. I'm having trouble to make TCC differentiate source code from standard input to be read from ```scanf``` commands later. Do you know if that's possible? – André Willik Valenti Nov 20 '17 at 13:50
I'm not sure if you mean Turbo C or Tiny C Compiler.
With Turbo C it can be as easy as:
tcc.exe myfile.c
This will produce myfile.exe
if all the source code is in myfile.c
.
If you run tcc.exe
without parameters it will show what parameters it accepts.
There's documentation for Tiny C Compiler and it probably can show its usage too if run without parameters or with a specific parameter like -?
or -help
.

- 61,140
- 12
- 83
- 180
I try the two ways as follows. Both the first and the second are ok. But the thrid one could not work.
1. Run the script in the command line:
$ echo 'main(){puts("Hello World");}' | tcc -run -
<stdin>:1: warning: implicit declaration of function 'puts'
Hello World
2. Build hello.c and run with the command
1). Build hello.c
#!/usr/bin/tcc -run
#include <stdio.h>
int main()
{
printf("Hello World\n");
}
2).call the application:
$ cd ./Documents/cfiles
$ tcc -run hello.c
Hello World
3. Run the lines one by one
I want to run codes one by one just like any Python script (>>>) on the Ubuntu Terminal, but it could not work.
$ tcc -run -
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
return 0;
}
main()

- 377
- 3
- 5