repo.or.cz/tinycc.git下载最新的snapshot压缩包,

或者用git命令下载: git clone git://repo.or.cz/tinycc.git

Linux下在路径下输入: ./configure && make && make install

Windows下先进入win32目录,使用vs2015或使用build-tcc.bat结合GCC[推荐环境为MSYS2]。

编译完成后的得到tcc的可执行文件。Windows下为tcc.exe以及辅助工具tiny_impdef.exe和tiny_libmaker.exe。

注:对于Windows,如果需要排除多余的.dll依赖,先要修改build-tcc.bat ,然后用tcc再编译一遍自己。

  最简单方法: tcc -DONE_SOURCE -DTCC_TARGET_PE tcc.c

  对于VS2017写了一个run.bat,可以改成其他版本:

git.exe clone http://repo.or.cz/tinycc.git 
@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
@mkdir tcc
@cd tinycc\win32
@call build-tcc.bat -c cl -t 32 -i ..\..\tcc
@cd ..
@pause
@cls
..\tcc\tcc.exe -DONE_SOURCE -DTCC_TARGET_PE -run tcc.c

  你甚至可以进行编译器的自举: ..\tcc\tcc.exe -DONE_SOURCE -DTCC_TARGET_PE -run tcc.c -DONE_SOURCE -DTCC_TARGET_PE -run tcc.c  

2.TCC配置

tcc最吸引人的特点是把C语言当脚本运行,即 tcc -run filename.c

HelloWorld.c的例子:

1 #include <stdlib.h>
2 #include <stdio.h>
3 
4 int main()
5 {
6     printf("Hello World\n");
7     return 0;
8 }
View Code

相关文章: