在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:12:12  来源:igfitidea点击:

Compile and run a file.c using Tiny C Compiler on Windows

cwindowscompiler-constructiontcc

提问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:

我已经有一些问题:

  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').
  1. 我将下载的所有 TCC 文件粘贴在哪里?
  2. 我是否必须编译 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

  1. you put the files wherever you like.

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

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

  2. 不,您无需编译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, tccshould 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 tcci 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.