Ubuntu9.10 gcc as ld编译Hello world 不能生成执行文件
Ubuntu9.10上 终端中
//***************************
//C语言程序 文件名为ctest.c
//程序
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0 ;
}
//***************************
用gcc -S ctest.c
产生ctest.s文件
//****************************
.file "ctest.c"
.section .rodata
.LC0:
.string "Hello world!"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
movl $.LC0, (%esp)
call puts
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (Ubuntu 4.4.1-4ubuntu8) 4.4.1"
.section .note.GNU-stack,"",@progbits
//***************************************************
然后 as -o ctest.o ctest.s
生成ctest.o
然后 ld -o ctest ctest.o
接着就出现以下提示:
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074
ctest.o: In function `main':
ctest.c:(.text+0x11): undefined reference to `puts'
没产生执行文件ctest
问题出现在哪里