|
|
linux0.11下,我编了个简单的hello.c程序,想了解main()怎样编译、链接成可执行程序的:
#include "stdio.h"
int main()
{
char c;
while(1)
{
scanf("%c",&c);
printf("%c",c);
}
return 0;
}
1、使用gcc -o hello hello.c,一切正常,但是这太智能了,我无法了解hello生成的大概过程
2、现在把编译、链接分开:
a. gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs\
-c -o hello.o hello.c
b. gld -s -x -M -o hello /usr/local/lib/crt0.o -L/usr/local/lib/ -lc \
hello.o
问题出在步骤b,出现错误:“Undefined symbol _printf...”和“Undefined symbol _scanf...”。请问printf、scanf在哪个库呢?有没有什么命令能查到它们在哪?GCC有没有什么选项能把它执行过程中使用到的库列出来吗? |
|