在 Windows 上使用 Tiny C Compiler 编译并运行 file.c
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5031529/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compile and run a file.c using Tiny C Compiler on Windows
提问by Eric Brotto
Could I get a step by step on how to compile my file.c using Tiny C Compiler and Windows prompt?
我可以逐步了解如何使用 Tiny C Compiler 和 Windows 提示符编译我的 file.c 吗?
Some questions I already have:
我已经有一些问题:
- Where do I stick all TCC files from the download?
- Do I have to compile stdio.h to use the printf function? (I'd like to do a 'Hello World').
- 我将下载的所有 TCC 文件粘贴在哪里?
- 我是否必须编译 stdio.h 才能使用 printf 函数?(我想做一个“Hello World”)。
This is what my file.c looks like:
这是我的 file.c 的样子:
// #include <stdio.h> // for printf
int main(void){
printf("Hello Eric. You've compiled and run the program! \n");
}
Thanks,
谢谢,
EDIT 1
编辑 1
So far I'm running it and getting the error: include file 'stdio.h' not found.
到目前为止,我正在运行它并收到错误:找不到包含文件“stdio.h”。
采纳答案by akira
you put the files wherever you like.
no, you do not need to compile
stdio.h
in order to use theprintf()
function.
你把文件放在任何你喜欢的地方。
不,您无需编译
stdio.h
即可使用该printf()
功能。
the tcc-distribution (tcc-0.9.25-win32-bin\tcc) consists of this:
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\
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
则应立即使用(我几秒钟前编译了 hello.c)。如果您将文件分开或其他东西不起作用:
% 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:
通过查看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)));
so, per default it assumes the libs and the headers to be in the place right next to the tcc.exe
.
因此,默认情况下,它假定库和标头位于tcc.exe
.