编译和链接

 #include <stdio.h>
  int main()
  {
  
          printf("Hello World\n");
          return 0;
  }

         
Linux 下 GCC 
1.预编译
gcc -E hello.c -o hello.i
或cpp hello.c>hello.i
2.编译
gcc -S hello.i -o hello.s

以上可以通过:gcc -S hello.i -o hello.s
也可以直接调用/usr/lib/gcc/i486-linux-gnu/4.3/ccl hello.c
3.汇编
  as hello.s -o hello.o
或者 gcc -c hello.s -o hello.o
以上过程可以直接:gcc -c hello.c -o hello.o
4.链接 
ld -static /usr/lib/crt1.o /usr/lib/crti.o
 /usr/lib/gcc/i486-linux-gnu/4.3/crtbeginT.o 
-L/usr/lib/gcc/i486-linux-gnu/4.3 -L/usr/lib 
-L/lib hello.o --start-group -lgcc -lgcc_eh -lc 
--end-group /usr/lib/gcc/i486-linux-gnu/4.3/crtend.o
 /usr/lib/crtn.o
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: