Ubuntu9.10 gcc as ld编译Hello world 不能生成执行文件

wengwen89 wengwen89 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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




问题出现在哪里
...全文
评论 6
收藏 已收藏
分享
返回顶部
wengwen89
汇编语言 21,500 成员 41,619 内容