autotools:C编译器无法创建可执行文件

时间:2012-04-12 14:16:02

标签: cross-compiling autotools osdev

我正在OS X上构建一个x86_64-elf内核。我的构建系统是autotools。我在OS X上成功编译了gcc以交叉编译x86_64-elf。当我运行从autotools生成的configure脚本时,我遇到了一个问题:

configure: error: C compiler cannot create executables
See `config.log' for more details

所以我看一下config.log并看看:

cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status

这很有道理。交叉编译器不会生成可执行文件,因为没有关联的运行时。但我不需要或希望我的编译器生成可执行文件,我将为我的引导程序适当地链接它。我怎么告诉autotools不检查这个?

2 个答案:

答案 0 :(得分:2)

确保在运行configure脚本时指定以下gcc标志(将它们添加到CFLAGS环境变量中):

-nostdlib -nostartfiles -nodefaultlibs -ffreestanding

如果您不知道如何将这些附加到CFLAGS的末尾,请尝试以下操作:

export CFLAGS=$CFLAGS -nostdlib -nostartfiles -nodefaultlibs -ffreestanding

答案 1 :(得分:0)

尝试:

DARWIN_VERSION_FULL=darwin`uname -r`
./configure --build=x86_64-apple-${DARWIN_VERSION_FULL} --host=x86_64-unknown-linux

现在configure应处于交叉编译模式,并停止运行该测试。