2

Could I get a step by step on how to compile my file.c using Tiny C Compiler and Windows prompt?

Some questions I already have:

  1. Where do I stick all TCC files from the download?
  2. Do I have to compile stdio.h to use the printf function? (I'd like to do a 'Hello World').

This is what my file.c looks like:

// #include <stdio.h> // for printf 
int main(void){
printf("Hello Eric. You've compiled and run the program! \n");
}

Thanks,


EDIT 1

So far I'm running it and getting the error: include file 'stdio.h' not found.

Jonas
131k103 gold badges330 silver badges408 bronze badges
asked Feb 17, 2011 at 16:14

1 Answer 1

2
  1. you put the files wherever you like.

  2. no, you do not need to compile stdio.h in order to use the printf() function.

the tcc-distribution (tcc-0.9.25-win32-bin\tcc) consists of this:

 tcc.exe
 tiny_impdef.exe
 tiny_libmaker.exe
 include\
 stdio.h ...
 lib\
 libtcc1.a ...
 doc\
 examples\ 

if you do not tear that order apart, tcc should work out of the box (i compiled a hello.c seconds ago). if you separated the files or something else does not work:

% tcc.exe -Ipath/to/include/folder/of/tcc input.c -L/path/to/lib/folder/of/

by looking at the source code of tcc i found this:

/* on win32, we suppose the lib and includes are at the location
 of 'tcc.exe' */
char path[1024], *p;
GetModuleFileNameA(NULL, path, sizeof path);
p = tcc_basename(normalize_slashes(strlwr(path)));

so, per default it assumes the libs and the headers to be in the place right next to the tcc.exe.

answered Feb 17, 2011 at 16:33
Sign up to request clarification or add additional context in comments.

5 Comments

Could you explain a bit what you are doing in that first chunk of code? Are those commands I enter into the prompt before running my code?
@Eric Brotto: the first block is the listing of the files in the tcc distribution. the second block is something you could type into your prompt.
Thanks and excuse me for my ignorance. So I basically just run that seccond block of code (the one liner) and I should be okay?
@Eric Brotto: if you keep the files of the tcc distribution intact, then you just run tcc.exe file.c
This worked! You rock! Thanks for getting back to my comments :)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.