2

我可以逐步了解如何使用 Tiny C 编译器和 Windows 提示符编译我的 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'。

4

1 回答 1

2
  1. 你把文件放在你喜欢的地方。

  2. 不,您无需编译stdio.h即可使用该printf()功能。

tcc-distribution (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.exe -Ipath/to/include/folder/of/tcc input.c -L/path/to/lib/folder/of/

通过查看tcc我发现的源代码:

/* 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.

于 2011-02-17T16:33:15.137 回答