我试图在我的mac pro上使用i386-elf-gcc学习操作系统。 Os版本是Sierra。我通过在bash中键入sudo port install i386-elf-gcc
来使用Macports来安装编译环境。但是当我编译一个helloworld程序时,它就出错了。
gcc hello.c
/opt/local/lib/gcc/i386-elf/4.7.2/../../../../i386-elf/bin/ld: cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
然后我使用sudo find / -name "crt0.o"
,但在我的mac中只有crt1.o,crt3.o等等。我使用-nostdlib和-nostartfiles它仍然出错:
gcc -nostdlib -nostartfiles hello.c
/opt/local/lib/gcc/i386-elf/4.7.2/../../../../i386-elf/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000008048054
/var/folders/wc/0c_zn09x12s_y90ccmvjb6900000gn/T//cc384VWr.o: In function `main':
hello.c:(.text+0x11): undefined reference to `puts'
collect2: error: ld returned 1 exit status
哦,天哪。希望有人救我。谢谢!