ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linux Ï C ±à³Ì´ÓÁ㿪ʼ

·¢²¼Ê±¼ä:2005-05-10 00:11:21À´Ô´:ºìÁª×÷Õß:thej
ÕâÀïÏò´ó¼Ò½éÉÜÒ»ÏÂÔÚLinux/UNIX µÄ»úÆ÷ÉÏ£¬½øÐÐ C/C++ ±à³ÌµÄһЩÈëÃż¶ÖªÊ¶¡£

? ËùÐè¾ß±¸µÄ±³¾°ÖªÊ¶
? ¿ª·¢ËùÐèµÄ»ù±¾»·¾³
? »ñµÃ°ïÖúµÄ;¾¶
? ͨ¹ýÒ»¸öʵÀýÁ˽â»ù±¾²½Öè


Prerequisite ÏȾöÌõ¼þ£º
ÔÚLinuxÉϱàд C ³ÌÐò£¬ÖÁÉÙÒªÊìϤÒÔÏÂÁ½·½ÃæµÄ»ù´¡ÖªÊ¶£º

1£® CÓïÑԵıà³Ì»ù´¡£¬ÖÁÉÙÒªÖªµÀһЩ»ù±¾µÄÓï·¨£¬¿ØÖÆÁ÷³ÌµÈ±à³Ì³£Ê¶¡£
¶Ô³£Óõıê×¼ C º¯Êý¿âÓг£Ê¶ÐÔµÄÁ˽⡣

2£® ¶ÔLinux/UNIX µÄ²Ù×÷Óг£Ê¶ÐÔµÄÁ˽⣬ÕÆÎÕ³£ÓõÄshell ÃüÁÈç ls, cat, cp, mkdir ¡­etc.


Environment ËùÐè»·¾³:

1£® Linux/ Unix µÄ²Ù×÷ϵͳ£¬Ò²¿ÉÒÔʹÓÃwindowsϵÄcygwin¡£

ÎÒÃÇÕâÀïÌÖÂ۵Ķ¼ÊÇͨ¹ýshellÃüÁîÐнøÐвÙ×÷µÄ¡£ÄÇÈç¹û½øÈëÁËͼÐνçÃæµÄLinux Ôõô°ìÄØ£¿Ö»Òª´ò¿ªÒ»¸öÖÕ¶ËÃüÁ¾ÍºÍÃüÁîÐл·¾³ÍêÈ«Ò»ÑùÁË£¨´ò¿ª¿ªÊ¼²Ëµ¥¿ÉÒÔÕÒµ½ÖÕ¶ËÃüÁ¡£

2£® ±Ø±¸µÄ¿ª·¢¹¤¾ß£º

1) ÊäÈë³ÌÐòÐèÒªÒ»¸ö±à¼­Æ÷¡£³£ÓõÄÓÐ vi , emacs. ÔÚÃüÁîÐÐÉÏÊäÈë vi, emacs, ¡­ ¾Í¿É½øÈë±à¼­»·¾³
¹ØÓÚ vi
¹ØÓÚ EMACS

2) CÓïÑԵıàÒëÆ÷¡£³£ÓõÄÊÇGNUµÄcÓïÑÔ±àÒëÆ÷ gcc(±àÒë C ³ÌÐò), g++(±àÒë C ++³ÌÐò)¡£
¹ØÓÚ gcc / g++
¹ØÓÚ makefile >>>> ÓÃÓÚ¼ò»¯±àÒë¹ý³Ì
ÕâÀïÓÐһƬÈëÃÅÎÄÕ LinuxÏÂCÓïÑÔ±à³Ì»ù´¡ÖªÊ¶£¬¿ÉÒÔÏÈ¿´Ò»ÏÂ

3) µ÷ÊÔ³ÌÐòµÄ³£Óù¤¾ß£ºgdb.
¹ØÓÚ gdb


Get help»ñµÃ°ïÖú£º

¹ØÓÚ Linux µÄÎĵµÊǷdz£·á¸»µÄ¡£×î¿ì½Ý£¬·½±ã£¬È«ÃæµÄ×ÊÁϾÍÔÚÄãµÄ»úÆ÷À²»ÒªÀË·Ñ¡£

ÔÚÃüÁîÐÐÉÏÊäÈëshellÃüÁî man »òÕß info£º
$man gcc >>>> Õâ¸öÃüÁî¿ÉÒÔ»ñµÃGNU µÄCÓïÑÔ±àÒëÆ÷µÄÎĵµ¡£µ±È»£¬ËûÃÇÊÇÓ¢Îĵġ£
¹ØÓÚ man
¹ØÓÚ info

ÍøÂçÉϵÄ×ÊÔ´Ò²ºÜ¶à£¬¶àµÃÒÔÖÁÓÚ²»ÖªµÀʲô²ÅÊÇ×Ô¼º×îÐèÒªµÄ¡£
¹ØÓÚÈçºÎ»ñµÃÓмÛÖµµÄÐÅÏ¢

¿´Ò»Ï loveunix ÉϵÄÏà¹Ø×ÊÔ´ >>>>

ÎÞË«²¹³äµÄһЩLinuxÏÂÈëÃűà³Ì×ÊÁÏ >>>>

¡¡

Basic steps »ù±¾²½Ö裺

1£® ÊäÈëÔ´´úÂë
2£® ±àÒ룬Á´½Ó£¬ÔËÐÐ
3£® µ÷ÊÔ³ÌÐò

ÎÒÃÇ´Ó×î»ù±¾µÄ hello world ³ÌÐò¿ªÊ¼£¬Êµ¼Ê²Ù×÷һϣº

1£® ÊäÈëÔ´´úÂë
ÒýÓÃ

$ emacs hello.c >>>> ½øÈëemacs ±à¼­Æ÷»·¾³

#include >>> Èç¹ûÄã¿´²»¶®Õâ¸öº¯Êý£¬¾ÍÈ¥ºÃºÃµÄ¿´cÓïÑÔµÄÊé
int main()
{
printf(¡°Hello World.\n¡±); >>>> Emacs»·¾³Ï£¬°´Ï Tab ¼ü£¬ÓÐ×Ô¶¯Ëõ½ø¹¦ÄÜ
exit(0);
}


Íê³ÉÊäÈëºó£¬°´×¡CTRL ¼ü£¬°´Ï x, ÔÙ°´Ï c , ×îºóËÉ¿ª CTRL¡£ >>>> ³ÌÐò±£Áô²¢Í˳öemacs »·¾³¡£

2£® ±àÒ룬Á´½Ó£¬ÔËÐÐ

ÒýÓÃ
$ gcc -o hello hello.c
$ ./hello >>>> ./ Ö¸Ã÷ÁËËùÖ´ÐгÌÐòµÄ·¾¶
Hello World.
$

Ò»¸ölinuxƽ̨ÉϵÄc³ÌÐò¿ª·¢ÒѾ­Íê³É¿©

3£® µ÷ÊÔ

Èç¹ûҪʹÓà gdb µ÷ÊÔ³ÌÐò£¬ÄÇôÔÚÉÏÒ»²½±àÒëµÄʱºò£¬¼ÇµÃ¼ÓÉÏ -g Ñ¡Ïî


ÒýÓÃ
$ gcc -g -o hello hello.c
$ gdb hello >>>> ½øÈë gdb µ÷ÊÔ»·¾³

¡¡

4. CVS°æ±¾¿ØÖÆÈí¼þ ---- Эͬ¹¤×÷ºÍ±£Áô°æ±¾µÄ¹¤¾ß
¹ØÓÚ CVS
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 134 ÌõÆÀÂÛ

  1. RED_CSHAT ÓÚ 2009-11-25 13:18:21·¢±í:

    Õä²Ø

  2. lightyear ÓÚ 2009-11-19 16:41:00·¢±í:

    Â¥Ö÷µÄ½éÉÜÄܲ»ÄÜÔÙ¾ßÌåһЩ

  3. ybg0631 ÓÚ 2009-11-19 14:31:21·¢±í:

    ¸Ð¾õºÜºÃ ¶¥

  4. linuxapple ÓÚ 2009-11-18 22:45:22·¢±í:

    ºÃ

  5. dert ÓÚ 2009-10-10 17:18:07·¢±í:

    ¶¥

  6. Knight_yj ÓÚ 2009-10-10 09:36:51·¢±í:

    ¶¥Æð

  7. pzcxujia ÓÚ 2009-10-10 09:23:38·¢±í:

    Ö§³Ö

  8. rxy24 ÓÚ 2009-10-09 18:12:19·¢±í:

    ѧϰÁË~

  9. yitian2000 ÓÚ 2009-10-08 17:13:19·¢±í:

    л£¡ÕýÏëѧѧC°¢

  10. huwei025 ÓÚ 2009-10-07 09:44:10·¢±í:

    10# chentong¶¨

  11. liu351128 ÓÚ 2009-10-05 22:04:25·¢±í:

    ¶ÔÐÂÊÖºÜÓÐÓÃ

  12. rxy24 ÓÚ 2009-10-05 21:28:56·¢±í:

    ºÇºÇºÇ~~¶¥~

  13. iltwq ÓÚ 2009-09-26 21:35:42·¢±í:

    ºÜºÃ£¬Ñ§Ï°ÁË

  14. wenzq ÓÚ 2009-09-25 14:41:11·¢±í:

    дµÄºÜÇåÎúºÍÒ׶® лл£¡

  15. realzheng ÓÚ 2009-09-18 23:14:25·¢±í:

    ѧϰÁË

  16. js001sdx ÓÚ 2009-09-17 15:50:10·¢±í:

    10# chentong

    UP!UP!UP!UP!UP!

  17. diaodazhi ÓÚ 2009-09-14 16:15:03·¢±í:

    Ì·ºÆÇ¿µÄ C³ÌÐòÉè¼Æ

  18. qiner ÓÚ 2009-08-28 18:46:16·¢±í:

    ¶¥

  19. zcc1984 ÓÚ 2009-07-24 11:23:26·¢±í:

    ÊÕÏÂ

  20. hice0000 ÓÚ 2009-07-22 14:37:48·¢±í:

    ѧϰÖС£¡£¡£

  21. balini ÓÚ 2009-07-22 14:33:53·¢±í:

    ¶¥

  22. guilincxl ÓÚ 2008-06-29 20:02:55·¢±í:

    лл·ÖÏí

  23. unicafree ÓÚ 2008-06-25 17:07:20·¢±í:

    ¾ÍÕâÑù¾ÍÍêÍêÁËÂ𣬻¹ÓÐʲô¶«Î÷Âð

  24. yannanfei169 ÓÚ 2008-06-25 15:57:48·¢±í:

    ¿´¿´ÁË

  25. Gones ÓÚ 2008-06-14 19:05:43·¢±í:

    I did it just now.
    From the screen,i see "Hello world".
    It's great.

  26. zzl7709 ÓÚ 2008-06-11 16:54:30·¢±í:

    OK

  27. Y2K ÓÚ 2007-05-22 15:20:57·¢±í:

    Õâ¾ÍûÁË°¡£¬Ì«ÉÙÁË°¡

  28. addlyl ÓÚ 2007-05-20 22:06:49·¢±í:

    :handshake ¶¥ÁË£¬¿´²»µ½Êéѽ£¬ÊDz»ÊÇȨÏÞ²»¹»Ñ½
    ¸øÎÒ·¢Ò»¸öÁË

  29. Gpoyinsnbo ÓÚ 2007-04-18 10:51:56·¢±í:

    лл·ÖÏí

  30. geniusmali ÓÚ 2007-03-29 14:26:41·¢±í:

    Ôõô¿´²»µ½ÏÂÔØÁ´½Ó°¡£¿

  31. geniusmali ÓÚ 2007-03-29 14:26:10·¢±í:

    ¡±1£® CÓïÑԵıà³Ì»ù´¡£¬ÖÁÉÙÒªÖªµÀһЩ»ù±¾µÄÓï·¨£¬¿ØÖÆÁ÷³ÌµÈ±à³Ì³£Ê¶¡£
    ¶Ô³£Óõıê×¼ C º¯Êý¿âÓг£Ê¶ÐÔµÄÁ˽⡣¡°¡£¡£¡£¡£¡£ÎÒÏëÂò±¾ÊéÀ´¿´¿´£¬ÇëÎÊÄı¾Êé½ÏÊʺÏ0»ù´¡µÄ¶ÁÕßѧϰCÓïÑÔ¡£µ±È»ÍøÉÏÒ²ÓÐÕâ·½ÃæµÄ×ÊÁÏ£¬²»¹ý»¹ÊÇÖ½Ó¡µÄÊé±ãÓÚÔĶÁ¡£

  32. honckly ÓÚ 2007-02-14 01:17:02·¢±í:

    ÊܽÌÁË£¡£¡:0L

  33. ph_degrees ÓÚ 2007-02-10 20:55:32·¢±í:

    LINUXµÄCÓïÑԵıà³Ì»ù´¡ÄÄÓÐÂô

  34. monther ÓÚ 2007-01-26 10:38:00·¢±í:

    ºÃ£¬?

  35. honckly ÓÚ 2007-01-17 17:40:43·¢±í:

    ´Óo¿ªÊ¼£¡£¡Ò»¶¨Òª¼á³Ö£¡£¡£¡

  36. linuxeden ÓÚ 2007-01-13 22:16:02·¢±í:

    :0L
    ллÌṩÊÕÏÂÁË

  37. twwlx101 ÓÚ 2007-01-11 08:43:01·¢±í:

    :mad:1
    ÎÒÒ²ÊÇ°´ÕÕÕâ¸ö·½·¨×öµÄ
    ¿ÉÊÇÕÒ²»µ½hello.cÕâ¸öÎļþ

  38. chris_cheng ÓÚ 2007-01-10 13:13:09·¢±í:

    Ïêϸ£¬¼òµ¥~£¡

  39. twwlx101 ÓÚ 2007-01-09 08:13:57·¢±í:

    ÎÒÔõôʲôҲû¿´µ½ÄØ£¿
    ºÇºÇ

  40. ÃÔ;СÊéͯ ÓÚ 2007-01-08 10:11:58·¢±í:

    ·Ç³£¸Ðл£¡£¡£¡