ºìÁª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. lwinon ÓÚ 2005-11-04 22:10:46·¢±í:

    ÆÚÍûÓиü¶à

  2. win-linux ÓÚ 2005-11-01 00:28:21·¢±í:

    ºÜºÃ

  3. ÐǹâÒÀÈ» ÓÚ 2005-10-11 00:31:52·¢±í:

    Ö§³Ö

  4. koov ÓÚ 2005-09-19 10:55:40·¢±í:

    ºÃÎÄÕÂ

  5. linux ÓÚ 2005-08-22 00:30:49·¢±í:

    ´Ó0¿ªÊ¼

  6. chentong ÓÚ 2005-07-25 00:15:25·¢±í:

    ¶¥

  7. zz123 ÓÚ 2005-06-29 00:14:41·¢±í:

    ¶¥

  8. HR ÓÚ 2005-06-18 16:10:37·¢±í:

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

  9. ÖйúÈË ÓÚ 2005-06-18 01:08:54·¢±í:

    ºÃÎÄ

  10. ÐÂРÓÚ 2005-06-07 14:26:51·¢±í:

    ÎÒ¶¥

  11. 007 ÓÚ 2005-06-01 00:28:36·¢±í:

    ꝃ즴

  12. cooc ÓÚ 2005-05-29 00:16:59·¢±í:

    UP

  13. ·çÓêÎÞ×è ÓÚ 2005-05-22 00:16:15·¢±í:

    ¶¥

  14. yangzi ÓÚ 2005-05-10 09:29:25·¢±í:

    ¶àл£¬ÊÕµ½¡£