我可以逐步了解如何使用 Tiny C 编译器和 Windows 提示编译我的 file.c 吗?
一些我已经有的问题:
- 将下载的所有 TCC 文件粘贴到哪里?
- 是否必须编译 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”。
最佳答案
您可以将文件放在任何您喜欢的地方。
不,您不需要编译
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)));
因此,默认情况下,它假定库和 header 位于 tcc.exe
旁边的位置。
关于在 Windows 上使用 Tiny C Compiler 编译并运行 file.c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5031529/