According to the steps of "install, compile and test" of "Ubuntu under GTK" (http://www.cnblogs.com/niocai/archive/2011/07/15/2107472.html), we have finally successfully installed GTK, very happy, Thought that the last one months of trouble to solve, but in the Eclipse IDE for C + + developes in a test, there is no Gtk/gtk.h header file found error. Cry!
It took a while to finally find the Ubuntu under Eclipse Configuration (http://blog.csdn.net/sunny2038/article/details/7082164), finally in the Eclipse IDE for C + + Developers found Gtk/gtk.h head file, thought finally boil out, behold test, incredibly out hundreds of errors, mainly similar to the following error and warning (G.C is the source file name):
In file included from/usr/include/gtk-2.0/gtk/gtk.h:170, from.. /g.c:1:
/usr/include/gtk-2.0/gtk/gtkspinner.h:58:error:expected ' = ', ', ', '; ', ' asm ' or ' __attribute__ ' before ' Gtk_spinner_ Get_type '
In file included From/usr/include/gtk-2.0/gtk/gtk.h:171,from. /g.c:1:
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:63:warning:parameter names (without types) in function declaration
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:63:error:field ' Gseal ' declared as a function
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:65:warning:parameter names (without types) in function declaration
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:65:error:bit-field ' gseal ' has invalid type
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:55:error:duplicate member ' Gseal ' ...
Many of the header files have similar errors, Baidu no fruit, and did not recruit, how is good? Beg Daniel to help ... anxiously waiting in!!!
---------------the following reprint from: Windows and Ubuntu11.10 configure C and GTK in Eclipse--------------------------------------------------
The GTK program running C in Eclipse under Ubuntu
1, download the relevant package
sudo apt-get install gnome-core-devel build-essential libgtk2.0-dev Libgtk2.0-doc
2. Test code
Open Eclipse, new--c project--Enter project name, and select Hello World ANSI C project in executable, choose Linux gcc toolchains by default, click finish- -This will open a sample code for Hello World--replace the code with the one in it with the following test code. (You can actually do this without the Hello World template, this is just a simplification process.) )
<span style="font-size:14px;">#include <gtk/gtk.h>
int main( int argc, char *argv[] )
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_main ();
return 0;
}</span>
3. Configuring Eclipse
(1) Select the GTK project and click project--properties--c/c++ BUILD--SETTINGS--GCC C compiler--miscellaneous in the menu bar to add ' Pkg-config–cflags gtk+-2.0 '
(2) In the same dialog box, select GCC C linker--miscellaneous, and add ' pkg-config–libs gtk+-2.0 ' in Linker flags
(3) Select GCC C Linker, in the right COMMAND line pattern inside the ${inputs} to ${command}, such as: ${command} ${inputs} ${flags} ${output_flag}${ Output_prefix}${output}
(4) in GCC C compiler--includes, adding/usr/include/gtk-2.0 and/usr/include/glib-2.0, can eliminate gtk.h unresolved warning, while using GTK function in the program , a smart prompt will appear.
After the above steps, a GTK program can be run out.
How do I run the C-language GTK program in Eclipse IDE for C + + developes under Ubuntu?