当前位置: 动力学知识库 > 问答 > 编程问答 >

cross compiling - autotools: C compiler cannot create executables

问题描述:

I am building an x86_64-elf kernel on OS X. My build system is autotools. I successfully compiled gcc to cross-compile for x86_64-elf on OS X. When I run the configure script generated from autotools I have an issue:

configure: error: C compiler cannot create executables

See `config.log' for more details

So I look at config.log and see:

cannot find crt0.o: No such file or directory

collect2: error: ld returned 1 exit status

This makes perfect sense. The cross-compiler won't generate an executable because there is no associated runtime. But I don't need or want my compiler to generate an executable, I'm going to link it appropriately for my bootloader. How do I tell autotools to not check this?

网友答案:

Make sure that you are specifying the following gcc flags when you run the configure script (add them to the CFLAGS environment variable):

-nostdlib -nostartfiles -nodefaultlibs -ffreestanding

If you don't know how to append these to the end of CFLAGS, try something like:

export CFLAGS=$CFLAGS -nostdlib -nostartfiles -nodefaultlibs -ffreestanding
网友答案:

Try:

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

Now configure should be in cross compiling mode, and stop running that test.

分享给朋友:
您可能感兴趣的文章:
随机阅读: