How does the GTK program in the Eclipse IDE for C + + C + + developers execute in ubuntu? (Resolved)

Source: Internet
Author: User
Tags gtk



( has been resolved.) See Ubuntu 12.04 in the Eclipse IDE for C/C + + developers implementation of the GTK program



Follow the steps in "Install, compile, and test" (http://www.cnblogs.com/niocai/archive/2011/07/15/2107472.html) of Ubuntu under GTK, and the final installation succeeded Gtk, very happy, Think that the last one months of trouble to conquer. But in the Eclipse IDE for C + + developes a test. An error occurred that Gtk/gtk.h header file could not be found.



Cry!



        It took a while to finally find the configuration of Eclipse under Ubuntu (http://blog.csdn.net/ sunny2038/article/details/7082164), the Gtk/gtk.h header file can eventually be found in the Eclipse IDE for C + + developers. Thought finally boil out, unexpectedly tested, unexpectedly come out hundreds of errors (probably the package did not install successfully), 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 has no effect. What's the best way to do it? Beg Daniel to help ... anxiously waiting in.!!





---------------reproduced below from: Windows and Ubuntu11.10 configure C and GTK in Eclipse--------------------------------------------------
C-language GTK program implemented 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 executable in the Hello World ANSI C Project. By default, the Linux gcc toolchains is selected, and clicking finish--will open a demo sample code for Hello World--replace the code of the function with the following test code. (In fact, there is nothing to do with the Hello World template, this is simply a simplification process.)




#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; 
}


3. Configuring Eclipse
(1) Select the GTK project. In the menu bar click project--properties--c/c++ build--settings--gcc C compiler--miscellaneous, add ' pkg-config–cflags in other flags Gtk+-2.0 '
(2) In the same dialog box. Select GCC C linker--miscellaneous, 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, add/usr/include/gtk-2.0 and/usr/include/glib-2.0, can eliminate gtk.h unresolved warning, The same time you use GTK's functions in your program, smart hints appear.
After the above steps, a GTK program can be executed.






How does the GTK program in the Eclipse IDE for C + + C + + developers execute in ubuntu? (Resolved)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.