【发布时间】:2015-08-23 08:01:06
【问题描述】:
/* test.c */
void func1()
{
}
int main()
{
func1();
}
您好,我正在使用 C 编写内核代码。但是我测试了上面的代码以了解如何构建 C 内核代码。下面的命令是我给提示的。我在 Windows 8.1 上使用 MinGW。
gcc -c -m32 test.c
ld -o test -Ttext 0x00 -e _main test.o
但是这个错误是从 ld 发生的。
test.o:test.c:(.text+0x7): undefined reference to `__main'
所以,我尝试了不同的方法。将 -nostdlib 和 --freestanding 选项添加到 gcc。但结果是一样的。 __main 函数在 CRT0 中吗?我应该怎么做才能解决这个问题..?
【问题讨论】:
-
你试过
-e main吗? -
当然。但是发生了额外的错误。如下所示。
-
ld:警告:找不到入口符号 main;默认为 00000000 test.o:test.c:(.text+0x7): undefined reference to `__main'
标签: c gcc compilation mingw