2011-02-17 147 views
2

如何使用Tiny C编译器和Windows提示编译我的file.c文件?在Windows上使用Tiny C编译器编译并运行file.c

一些问题我已经有了:

  1. 我在哪里从下载坚持所有TCC文件?
  2. 我必须编译stdio.h才能使用printf函数吗? (我想做一个'Hello World')。

这是我的file.c的样子:

// #include <stdio.h> // for printf 

int main(void){ 
printf("Hello Eric. You've compiled and run the program! \n"); 
} 

感谢,


编辑1

到目前为止我运行它,并获得错误:包含文件'stdio.h'找不到。

回答

1
  1. 你把文件放在任何你喜欢的地方。不需要编译stdio.h以便使用printf()函数。

的TCC-分布(TCC-0.9.25-Win32的BIN \ TCC)由这样的:

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

,如果你不撕顺序分开,tcc应该制定出的盒子(我编译了hello.c几秒前)。如果你分开的文件或别的东西不工作:通过查看tcc源代码

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

我发现这一点:

/* 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))); 

所以,每默认它假定库和头到在tcc.exe旁边。

+0

你能解释一下你在做的第一块代码?在运行我的代码之前,这些命令是否进入提示? – 2011-02-17 16:37:19