【发布时间】:2018-09-09 12:42:06
【问题描述】:
我需要使用 TCC 编译器来链接 GCC 生成的目标文件。但是MinGW中的GCC以COFF格式输出目标文件,而TCC只支持ELF格式。如何让 GCC 生成 ELF 目标文件?
$ cat test.c
int main(void)
{
return 0;
}
$ gcc -c test.c
$ file test.o
test.o: MS Windows COFF Intel 80386 object file
$ tcc -c test.c
$ file test.o
test.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
【问题讨论】:
-
为什么不使用 gcc 链接可执行文件?我很确定 Windows 无论如何都无法运行 elf 可执行文件(至少,在不使用 WSL 的情况下不会)......