LinuxÏÂGCC±àÒëµÄËĸö¹ý³Ì
3ks:http://boz8.com/house/article.aspx?aid=112
ÔÚLinuxϽøÐÐCÓïÑÔ±à³Ì£¬±ØȻҪ²ÉÓÃGNU GCCÀ´±àÒëCÔ´´úÂëÉú³É¿ÉÖ´ÐгÌÐò¡£
Ò»¡¢GCC¿ìËÙÈëÃÅ
GccÖ¸ÁîµÄÒ»°ã¸ñʽΪ£ºGcc [Ñ¡Ïî] Òª±àÒëµÄÎļþ [Ñ¡Ïî] [Ä¿±êÎļþ]
ÆäÖУ¬Ä¿±êÎļþ¿Éȱʡ£¬GccĬÈÏÉú³É¿ÉÖ´ÐеÄÎļþÃûΪ£º±àÒëÎļþ.out
ÎÒÃÇÀ´¿´Ò»Ï¾µäÈëÃųÌÐò"Hello World£¡"
# vi hello.c
#include <stdlib.h>
#include <stdio.h>
void main(void)
{
printf("hello world!\r\n");
}
ÓÃgcc±àÒë³ÉÖ´ÐгÌÐò¡£
#gcc hello.c
¸ÃÃüÁhello.cÖ±½ÓÉú³É×îÖÕ¶þ½øÖÆ¿ÉÖ´ÐгÌÐòa.out
ÕâÌõÃüÁîÒþº¬Ö´ÐÐÁË£¨1£©Ô¤´¦Àí¡¢£¨2£©»ã±à¡¢(3)±àÒë²¢(4)Á´½ÓÐγÉ×îÖյĶþ½øÖÆ¿ÉÖ´ÐгÌÐò¡£ÕâÀïδָ¶¨Êä³öÎļþ£¬Ä¬ÈÏÊä³öΪa.out¡£
ÈçºÎÒªÖ¸¶¨×îÖÕ¶þ½øÖÆ¿ÉÖ´ÐгÌÐòÃû£¬ÄÇôÓÃ-oÑ¡ÏîÀ´Ö¸¶¨Ãû³Æ¡£±ÈÈçÐèÒªÉú³ÉÖ´ÐгÌÐòhello.exe
ÄÇô
#gcc hello.c -o hello.exe
¶þ¡¢GCCµÄÃüÁîÆÊÎö--ËIJ½×ß
´ÓÉÏÃæÎÒÃÇÖªµÀGCC±àÒëÔ´´úÂëÉú³É×îÖÕ¿ÉÖ´ÐеĶþ½øÖƳÌÐò£¬GCCºǫ́Òþº¬Ö´ÐÐÁËËĸö½×¶Î²½Öè¡£
GCC±àÒëCÔ´ÂëÓÐËĸö²½Ö裺
Ô¤´¦Àí-----> ±àÒë ----> »ã±à ----> Á´½Ó
ÏÖÔÚÎÒÃǾÍÓÃGCCµÄÃüÁîÑ¡ÏîÀ´Öð¸öÆÊÎöGCC¹ý³Ì¡£
1£©Ô¤´¦Àí(Pre-processing)
Ôڸý׶Σ¬±àÒëÆ÷½«CÔ´´úÂëÖеİüº¬µÄÍ·ÎļþÈçstdio.h±àÒë½øÀ´£¬Óû§¿ÉÒÔʹÓÃgccµÄÑ¡Ïî”-E”½øÐв鿴¡£
Ó÷¨£º#gcc -E hello.c -o hello.i
×÷Ó㺽«hello.cÔ¤´¦ÀíÊä³öhello.iÎļþ¡£
[root]# gcc -E hello.c -o hello.i
[root]# ls
hello.c hello.i
[root]# vi hello.i
# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "hello.c"
# 1 "/usr/include/stdlib.h" 1 3
# 25 "/usr/include/stdlib.h" 3
# 1 "/usr/include/features.h" 1 3
# 291 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 292 "/usr/include/features.h" 2 3
# 314 "/usr/include/features.h" 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 315 "/usr/include/features.h" 2 3
# 26 "/usr/include/stdlib.h" 2 3
# 3 "hello.c" 2
void main(void)
{
printf("hello world!\r\n");
}
2)±àÒë½×¶Î(Compiling)
µÚ¶þ²½½øÐеÄÊDZàÒë½×¶Î£¬ÔÚÕâ¸ö½×¶ÎÖУ¬GccÊ×ÏÈÒª¼ì²é´úÂëµÄ¹æ·¶ÐÔ¡¢ÊÇ·ñÓÐÓï·¨´íÎóµÈ£¬ÒÔÈ·¶¨´úÂëµÄʵ¼ÊÒª×öµÄ¹¤×÷£¬ÔÚ¼ì²éÎÞÎóºó£¬Gcc°Ñ´úÂë·Òë³É»ã±àÓïÑÔ¡£Óû§¿ÉÒÔʹÓÔ-S”Ñ
Ïà¹ØÎĵµ£º
´´½¨×ÀÃæͼ±ê
Ä¿Ç°½«ÍøÂçÓ¦ÓÃÀ©Õ¹µ½×ÀÃæÊÇÒ»¸öÇ÷ÊÆ£¬´æÔÚןܶà½â¾ö·½°¸£¬±¾ÎÄÒÔ Mozilla Prism ΪÀý£¬ÀàËƵķ½·¨Í¬ÑùÊÊÓÃÓÚ Google Chrome ¡£
1. µ½ Mozilla Prism µÄÍøÕ¾ÉÏÏÂÔØ Prism£¬µã»÷ Download Now Ö®ºó»áÌáʾÓÐÁ½ÖÖ£¬Ò»ÖÖÊÇÒÔ Mozilla Firefox À©Õ¹µÄ·½Ê½£¬ÊʺÏÒѾ°²×°ÓÐ Firefox µÄÅóÓÑ£»Ò»Ö ......
[¾«»ª] ÍêÈ«Óà GNU/Linux ¹¤×÷
http://www.chinaunix.net ×÷Õß:enfuzion ·¢±íÓÚ£º2005-12-08 16:05:56
¡¾·¢±íÆÀÂÛ¡¿¡¾²é¿´ÔÎÄ¡¿¡¾LinuxÌÖÂÛÇø¡¿¡¾¹Ø±Õ¡¿
ת×Ôhttp://www.chinaunix.net/jh/4/16102.html
ÍêÈ«Óà GNU/Linux ¹¤×÷
— ±÷Æú Windows µÍЧÂʵŤ×÷·½Ê½£¬·¢¾ò&n ......
STAT(¸ÃÐг̵Ä״̬)
D: ²»¿ÉÓÃÐźÅÖжϵÄ˯Ãß״̬
R: ÕýÔÚÖ´Ðлò´¦ÓÚÖ´ÐжÓÁÐÖÐ
S: ¿ÉÒÔÓÃÐźÅÖжϵÄ˯Ãß״̬
T: ÔÝÍ£Ö´ÐÐ
Z: ½©ËÀ״̬
££££££££££££££££££££££££££££££££££££
W: ûÓÐ×ã¹»µÄ¼ÇÒäÌå·ÖÒ³¿É·ÖÅä
<: ¸ßÓÅÏÈÐòµÄÐгÌ
N: µÍÓÅÏÈÐòµÄÐгÌ&nbs ......
wait(µÈ´ý×Ó½ø³ÌÖжϻò½áÊø)
±íÍ·Îļþ
#include<sys/types.h>
#include<sys/wait.h>
¶¨Ò庯Êý pid_t wait (int * status);
º¯Êý˵Ã÷
wait()»áÔÝʱֹͣĿǰ½ø³ÌµÄÖ´ÐÐ,Ö±µ½ÓÐÐźÅÀ´µ½»ò×Ó½ø³Ì½á
Êø¡£È ......
List_Head
²Ù×÷ϵͳÄں˾³£ÐèҪά»¤Êý¾Ý½á¹¹¡£ÄÚºËÓбê×¼µÄÑ»·Á´±í¡¢Ë«ÏòÁ´±íµÄʵÏÖ¡£ÔÚ<Linux/list.h>ÎļþÖж¨ÒåÁËÒ»¸ölist_headÀàÐͼòµ¥½á¹¹£º
struct list_head {
struct list_head *next, *prev;
};
ͨÓÃÁ´±íµÄ³£ÓÃÓÃ;Êǽ«Ä³Ò»¸öÊý¾Ý½á¹¹±¾Éí´®³ÉÁ´±í£¬»ò½«Ä³Ð©Á´±íÓëÒ»¸öÊý¾Ý½á¹ ......