红联Linux门户
Linux帮助

Install GCC, GTK in ubuntu

发布时间:2008-03-04 16:07:05来源:红联作者:Deaboot
After install Linux system, gcc also OK, but you can't use. It need some head file. Install build-essential pkg

#sudo apt-get install build-essential

after install finish, run below program check gcc can work

/* start testc.c*/

#include

int main()

{

printf("Hello Ubuntu!\n");

return 0;

}

/*finish testc.c*/

open terminal compile testc.c

$ gcc testc.c -o testc

$ ./testc

Check it show :Hello Ubuntu!



Install gtk

open terminal

$sudo apt-get install libgtk2.0-dev

after install finish, run below program check gtk can work

/*gtkhello.c start*/

#include

int main( int argc, char *argv[] )

{

GtkWidget *window;

gtk_init (&argc, &argv);

window=gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_signal_connect (GTK_OBJECT (window), "destroy",GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

gtk_widget_show (window);

gtk_main();

return(0);

}

/*gtkhello.c end*/

$ gcc gtkhello.c -o gtktest `pkg-config --cflags --libs gtk+-2.0`

$ ./gtktest

check it can show a window.

you can use below command to search gtk install pkg

$sudo apt-cache search libgtk
文章评论

共有 4 条评论

  1. chaipeng 于 2011-08-17 13:54:52发表:

    ym :0)1

  2. shengcheng 于 2009-12-08 15:27:23发表:

    why don't you said again in chinese?

  3. Serval 于 2009-12-06 12:42:01发表:

    Well, Thank you!
    I'm looking for information like this.

  4. tomorrow207 于 2009-12-02 10:27:54发表:

    恩,回去试试