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

µÚÒ»´ÎLinux±à³Ì£¬ÖµµÃÁôÄî

·¢²¼Ê±¼ä:2007-07-06 00:35:31À´Ô´:ºìÁª×÷Õß:patriotism
¡¡¡¡½ñÌ죬¿´ÁËһϡ¶LinuxϵͳӦÓÃÓ뿪·¢½Ì³Ì¡·µÄ¡°GCCµÄʹÓÃÓ뿪·¢¡±²¿·Ö£¬×Ô¼º½Ó´¥LinuxÒ²²»¶Ìʱ¼äÁË£¬Ö»²»¹ýÕæÕýŪ¶®LinuxµÄ¶«Î÷»¹ÉÙ£¬ÏÖÔÚ¾ÍÀ´ÍæÍæLinux±à³Ì¡£

¡¡¡¡Ç°Á½Ìì²Å°²×°µÄFedora 7.0Õýʽ°æ£¬Æô¶¯ÏµÍ³ºó£¬Ð½¨Ò»¸ö¿ÕÎļþhelloworld.c£¬ÇÃÈë³ÌÐò³õѧÕßʹÓõÄ×î¼òµ¥³ÌÐò´úÂ루ËäÈ»ÎÒѧCÒѾ­ÓÐÁ½Äê¶àÁË£©

#include
void main()
{
printf("Hello World!\n");
}

¡¡¡¡±£´æºóÔÚÖÕ¶ËÀïÊäÈëÃüÁî¡°gcc helloworld.c -o helloworld¡±£¬ÂíÉϻسµ£¬ÐÄÏë×Ô¼ºµÄµÚÒ»¸öLinux³ÌÐò¾ÍÒªµ®ÉúÁË£¬àÞ£¬My god£¬Ë­Öª³öÀ´µÄÊÇ´íÎóÌáʾ£¬Ëµmainº¯ÊýûÓзµ»ØintÐÍ£¬µ«ÉÏÃæµÄ´úÂëÔÚVCÀïÊÇ¿ÉÐеġ£ÎÞ°ì·¨£¬¸ÄΪ

#include
int main()
{
printf("Hello World!\n");
return 0;
}

¡¡¡¡ÔÙÖ´ÐÐÉú³ÉÃüÁÕâ´ÎʲôҲûÌáʾ£¬³É¹¦ÁË£¬¹þ¹þ~~~½Ó×ŵ±È»ÊÇÔËÐÐ×Ô¼ºµÄµÚÒ»¸öLinux³ÌÐò¿´¿´½á¹ûÀ²£¬ÔÚÖÕ¶ËÀïÊäÈë¡°helloworld¡±£¬àÞ£¬My god£¬ÌáʾûÓдËÃüÁÃ÷Ã÷³ÌÐò¾ÍÔÚµ±Ç°Ä¿Â¼°¡£¬¿´¿´ÊéÉÏÔõôдµÄ£¬ÖÕÓÚ·¢ÏÖÐèÒªÕâÑùдÃüÁî¡°./helloworld¡±£¬»Ø³µ£¬ÖÕÓÚ´òÓ¡³ö ¡°Hello World!¡±ÁË¡£ËäÈ»×Ô¼ºÐ´³ÌÐò½«½üÈýÄ꣬µ«ÔÚLinuxÉÏÁ¬´òÓ¡¡°Hello World!¡±»¹ÊÇÓöµ½Âé·³£¬Õâ¾ÍÊÇûÓж¯ÊÖµÄÔ­Òò¡£

¡¡¡¡½Ó×Åд¸öÓÐÒâ˼µãµÄ----´°Ìå³ÌÐò£¬°´ÕÕÊéÉÏʹÓÃGTK+£¬°Ñhelloworld.c´úÂë¸Ä³É

#include
void on_btn_clicked(GtkWidget *widget, gpointer data)
{
g_print("Hello World!\n");
}
void on_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
{
g_print("Window Closed.\n");
gtk_main_quit();
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
gtk_set_locale();
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(on_delete), NULL);
button = gtk_button_new_with_label("Hello World");
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_btn_clicked), NULL);
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show_all(window);
gtk_main();
return 0;
}

¡¡¡¡È«ÊÇÄÇô³¤µÄº¯ÊýÃû£¬»¹ÓÐÄÇô¶àµÄÏ»®Ïߣ¬¿´ÁËÓеãÑÛ»¨£¬ÖÕÓÚ×Ô¼º´ò´íÁËÁ½¸öµ¥´Ê£¬¾­±àÒëʱ²ÅÌáʾµÄ¡£µ±ÎÒ´òºÃ´úÂëºó£¬°´ÕÕÊéÉÏËù˵µÄÃüÁî¡°gcc helloworld.c -o helloworld 'pkg-config gtk+-2.0 --cflags --libs'¡±£¬»Ø³µºóÈ´ÌáʾʲôÎÞ¡°pkg-config gtk+-2.0 --cflags --libs¡±£¬Ãþ²»×ÅÍ·ÄÔ£¬ÊéÉÏ˵ÊäÈë¡°pkg-config gtk+-2.0 --cflags --libs¡±¿ÉÒÔ¼ì²éËüµÄÊä³ö½á¹û£¬ÊäÈë»Ø³µÈ·Êµ³öÀ´Ò»¶Ñ×Ö·û£¬ÓÐʲôÓò»ÖªµÀ¡£ÔÙÊÔÉÏÃæµÄ±àÒëÃüÁ»¹ÊÇͬÑùµÄ´íÎó£¬Ôõô»ØÊ£¿ÊDz»ÊÇÊéÉÏÅÅ°æд´íÃüÁîÁË£¿ÂíÉÏ´ò¿ªFirefox£¬°Ù¶ÈÁËһϣ¬¿´µ½±ðÈËʹÓõÄÃüÁîºÍÎÒ´òµÄÓеãССµÄ²»Í¬£¬¾ÍÊÇÄǸöµ¥ÒýºÅ£¬ÎÒ´òµÄÊÇÕý¹æµÄÓ¢Îĵ¥ÒýºÅ£¬¶ø±ðÈËÓõÄÈ´ÊÇÏòÓÒбµÄ¡°µ¥ÒýºÅ¡±£¬ÔõôÄÇôÆæ¹Ö£¿ÊéÉÏÒ²ÊÇ˵ʹÓÃÒ»¶Ô·´Ïòµ¥ÒýºÅ£¬ÎÒÕÒ²»×Åʲô·´Ïòµ¥ÒýºÅÔÚÄÄÊäÈ룬¾Í°Ñ±ðÈ˵ÄCopy¹ýÀ´£¬±ä³É¡°gcc helloworld.c -o helloworld `pkg-config gtk+-2.0 --cflags --libs`¡±£¬¸´ÖÆÃüÁîµ½Öնˣ¬»Ø³µ£¬µÈÁËÒ»»á£¬×îºóʲô½á¹û¶¼Ã»ÓУ¬ºÇºÇ£¬³É¹¦À²£¡Ô­À´ÕæµÄÊÇÄǸöʲô·´Ïòµ¥ÒýºÅµÄÎÊÌ⣬ÎÒÔÙÊÔÁËһϼüÅÌ£¬»¹ÊÇÕÒ²»×Åʲô·´Ïòµ¥ÒýºÅ¡£ËãÁË£¬²»Àí£¬Ö´ÐеÚÒ»¸öLinux´°Ìå³ÌÐò¿´¿´£¬ÊäÈë¡°./helloworld¡±£¬»Ø³µ£¬¹þ¹þ£¬´°Ìå³öÀ´À²£¬Ö»ÓÐÒ»¸öºÜ³óµÄ°´Å¥£¬ºÜСµÄ´°Ì壬²îµãÕÒ²»×ÅËü³öÏÖÔÚÄÄÀ°´×î´ó»¯¸ü¹Ö£¬ÒòΪÄǸö°´Å¥Ò²¸ú×űä´óÁË£¬¹þ¹þ¡£

¡¡¡¡µÚÒ»´ÎLinux±à³ÌÊÇÕâÑùµÄʧ°Ü£¬ºô£¡ÖØÆô»Øµ½Windows 2003£¬Ð´ÏÂÕâƪÎÄÕ¡££¨Å¶£¬¶ÔÁË£¬ÄǸö·´Ïòµ¥ÒýºÅÔÚÕâ¸öʱºò¸øÎÒ¿´µ½ÁË£¬ÊÇÒ»¸ö·Ç³£ÉÙÓõķûºÅ£¬Ò²ÔÚÒ»¸ö·Ç³£ÉÙÓõİ´¼üÉÏÃ棬¾ÍÊǼüÅÌ×óÉϽÇEsc ¼üÏÂÃæÄǸö£¬Õâ¸ö½Ð·´Ïòµ¥ÒýºÅ£¬¹þ¹þ£©
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 2 ÌõÆÀÂÛ

  1. grdxyxy ÓÚ 2007-07-21 23:46:15·¢±í:

    Êǵģ¬Ò»¶¨ÒªÕâÑùд¡£

  2. Jorn ÓÚ 2007-07-15 10:38:00·¢±í:

    ¡°ÖÕÓÚ·¢ÏÖÐèÒªÕâÑùдÃüÁî¡°./helloworld¡±£¬¡±
    ΪʲôÐèÒªÕâÑùдÁË£¿£¿¸ã²»Ã÷°×£¬ÎÒÔÚÖ´ÐгÌÐòʱҲÐèÒªÕâÑùд£¿