Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: gtk programming problems

  1. #1
    Join Date
    Nov 2010
    Beans
    12
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Question gtk programming problems

    Hi all, I'm trying to do some programming with GTK.
    I have everything installed libs and includes and GTK applications run fine.
    But trying to compile this simple program...

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

    I get a whole bunch of errors.


    make all
    Building file: ../Test.cpp
    Invoking: GCC C++ Compiler
    g++ -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/lib/gtk-2.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Test.d" -MT"Test.d" -o"Test.o" "../Test.cpp"
    In file included from /usr/include/glib-2.0/glib/gtypes.h:35,
    from /usr/include/glib-2.0/glib/galloca.h:34,
    from /usr/include/glib-2.0/glib.h:32,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/glib/gmacros.h:47: warning: "G_GNUC_EXTENSION" redefined
    /usr/include/glib-2.0/glibconfig.h:38: note: this is the location of the previous definition
    In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:34,
    from /usr/include/glib-2.0/glib.h:34,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/glib/gthread.h:271: error: ‘GSystemThread’ does not name a type
    In file included from /usr/include/glib-2.0/glib/giochannel.h:35,
    from /usr/include/glib-2.0/glib.h:53,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/glib/gmain.h:136: error: typedef ‘GChildWatchFunc’ is initialized (use decltype instead)
    /usr/include/glib-2.0/glib/gmain.h:136: error: ‘GPid’ was not declared in this scope
    /usr/include/glib-2.0/glib/gmain.h:137: error: expected primary-expression before ‘status’
    /usr/include/glib-2.0/glib/gmain.h:138: error: expected primary-expression before ‘data’
    /usr/include/glib-2.0/glib/gmain.h:376: error: ‘GPid’ was not declared in this scope
    /usr/include/glib-2.0/glib/gmain.h:509: error: ‘GPid’ has not been declared
    /usr/include/glib-2.0/glib/gmain.h:510: error: ‘GChildWatchFunc’ has not been declared
    /usr/include/glib-2.0/glib/gmain.h:513: error: ‘GPid’ was not declared in this scope
    /usr/include/glib-2.0/glib/gmain.h:514: error: ‘GChildWatchFunc’ was not declared in this scope
    /usr/include/glib-2.0/glib/gmain.h:515: error: expected primary-expression before ‘data’
    /usr/include/glib-2.0/glib/gmain.h:515: error: initializer expression list treated as compound expression
    In file included from /usr/include/glib-2.0/glib.h:61,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/glib/gmessages.h:110: error: expected constructor, destructor, or type conversion before ‘void’
    In file included from /usr/include/glib-2.0/glib.h:78,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/glib/gspawn.h:92: error: ‘GPid’ has not been declared
    /usr/include/glib-2.0/glib/gspawn.h:105: error: ‘GPid’ has not been declared
    /usr/include/glib-2.0/glib/gspawn.h:135: error: variable or field ‘g_spawn_close_pid’ declared void
    /usr/include/glib-2.0/glib/gspawn.h:135: error: ‘GPid’ was not declared in this scope
    In file included from /usr/include/glib-2.0/gobject/gobject.h:26,
    from /usr/include/glib-2.0/gobject/gbinding.h:31,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/gobject/gtype.h:1665: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1666: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1667: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1668: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1669: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1670: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1671: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1672: error: expected constructor, destructor, or type conversion before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1673: error: expected constructor, destructor, or type conversion before ‘void’
    In file included from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.cpp:8:
    /usr/include/glib-2.0/gio/gioenums.h:630: error: ‘GLIB_SYSDEF_AF_INET’ was not declared in this scope
    /usr/include/glib-2.0/gio/gioenums.h:631: error: ‘GLIB_SYSDEF_AF_INET6’ was not declared in this scope
    /usr/include/glib-2.0/gio/gioenums.h:676: error: ‘GLIB_SYSDEF_MSG_OOB’ was not declared in this scope
    /usr/include/glib-2.0/gio/gioenums.h:677: error: ‘GLIB_SYSDEF_MSG_PEEK’ was not declared in this scope
    /usr/include/glib-2.0/gio/gioenums.h:678: error: ‘GLIB_SYSDEF_MSG_DONTROUTE’ was not declared in this scope
    /usr/include/glib-2.0/glib/gutils.h:301: warning: ‘gint g_bit_nth_lsf(gulong, gint)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gutils.h:303: warning: ‘gint g_bit_nth_msf(gulong, gint)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gutils.h:305: warning: ‘guint g_bit_storage(gulong)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gutils.h:316: warning: ‘void g_trash_stack_push(GTrashStack**, void*)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gutils.h:318: warning: ‘void* g_trash_stack_pop(GTrashStack**)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gutils.h:319: warning: ‘void* g_trash_stack_peek(GTrashStack**)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gutils.h:320: warning: ‘guint g_trash_stack_height(GTrashStack**)’ declared ‘static’ but never defined
    /usr/include/glib-2.0/glib/gthread.h:339: warning: ‘gboolean g_once_init_enter(volatile gsize*)’ declared ‘static’ but never defined
    make: *** [Test.o] Error 1



    There were some more but I discovered some declarations in various include files that were commented out. I removed the comments and some of those errors were gone.
    I'm thinking I have the wrong development package. I'm using the package that installed with Ubuntu 10.10

    I've also compared header files with these packages
    gtk+-2.22.0
    pango-1.28.3
    glib-2.26.0
    I can't find any differences
    Anybody have any ideas ??????


  2. #2
    Join Date
    Sep 2009
    Beans
    12
    Distro
    Ubuntu 9.10 Karmic Koala

  3. #3
    Join Date
    Nov 2010
    Beans
    12
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: gtk programming problems

    Thanks, but I've been there and done that.
    The compiler finds all the files it's looking for.
    The linker finds all the files it's looking for.
    There are definite problems with the set of development files that I have.
    I've tried Eclipse, Netbeans, Codelite, and direct from the command line with the files explicitly entered and with the pkg-config with the same result every time.
    Even compiling the assembler version of the same code yields the same results.
    I'm getting quite frustrated.

  4. #4
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: gtk programming problems

    Let's see...

    0. You say you installed GTK+... From where? How? You know the best way to do it is by installing the libgtk2.0-dev package... This may seem obvious, but sometimes people that use KDE fear that doing that will install the whole GNOME suite (which won't happen) and try installing GTK+ from source.

    1. You're using a really weird compiling command. The way to compile GTK+ applications is the following:

    Code:
    # Using gcc... see below
    gcc -o my_app my_app.c -Wall -Wextra -pedantic $(pkg-config --cflags --libs gtk+-2.0)
    I see you're using a Makefile. Please, post it... the bug is surely there.

    2. Use gcc and g++ properly. Your code, despite having the *.cpp extension is C, not C++... and GTK+ is C (gtkmm is C++). Ok, this may sound a bit snobbish or whatever, but it's always better to use the corresponding compiler... or you may get some quirks. It wouldn't be the first time we come across some error produced by trying to compile C code with g++ (no, C++ isn't a strict superset of C... and moreover, it changes some fundamental parts of C semantics). I compiled your code using g++ and I got no errors. Also, if you're going for C++ GTK+ programming, I highly recommend you to use gtkmm instead... gtkmm will make use of all OOP features C++ has and make everything much easier for you.

  5. #5
    Join Date
    Nov 2010
    Beans
    12
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: gtk programming problems

    Hey nvteighen, thanks for the response and the things to try.

    0. I'm using Ubuntu 10.10 with the gnome desktop, GTK+ is install with the system. I did install the libgtk2.0-dev package through the package manager.

    1.The compile command I used is generated by Eclipse, I also tried yours and I get the same errors only worded for C instead of C++

    Here's the Eclipse generated make file

    ################################################## ##############################
    # Automatically-generated file. Do not edit!
    ################################################## ##############################

    -include ../makefile.init

    RM := rm -rf

    # All of the sources participating in the build are defined here
    -include sources.mk
    -include subdir.mk
    -include objects.mk

    ifneq ($(MAKECMDGOALS),clean)
    ifneq ($(strip $(C++_DEPS)),)
    -include $(C++_DEPS)
    endif
    ifneq ($(strip $(C_DEPS)),)
    -include $(C_DEPS)
    endif
    ifneq ($(strip $(CC_DEPS)),)
    -include $(CC_DEPS)
    endif
    ifneq ($(strip $(CPP_DEPS)),)
    -include $(CPP_DEPS)
    endif
    ifneq ($(strip $(CXX_DEPS)),)
    -include $(CXX_DEPS)
    endif
    ifneq ($(strip $(C_UPPER_DEPS)),)
    -include $(C_UPPER_DEPS)
    endif
    endif

    -include ../makefile.defs

    # Add inputs and outputs from these tool invocations to the build variables

    # All Target
    all: Test

    # Tool invocations
    Test: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: GCC C++ Linker'
    g++ -L/usr/lib -L/lib -o"Test" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

    # Other Targets
    clean:
    -$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$( EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) Test
    -@echo ' '

    .PHONY: all clean dependents
    .SECONDARY:

    -include ../makefile.targets

    2. I know that the code should compile and run because everyone else can get it to work but me. I've tried gcc and g++. Ultimately I want to do my coding in assembler which should work fine using gcc and gtk. I'm just trying to get gtk development package working.

    I guess I can always just use X11 directly. (but I don't wanna)

    Any more idea's.... anyone....

  6. #6
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: gtk programming problems

    Quote Originally Posted by solaris235 View Post
    1.The compile command I used is generated by Eclipse, I also tried yours and I get the same errors only worded for C instead of C++
    Wait a minute. Did you use my command on Eclipse?

    Ugh... I see I didn't mention you to use it on a Terminal, rather than on the IDE. I haven't ever used Eclipse, so I don't know how it is supposed to work; what I want you to check is whether it is an IDE-related thing or something else is preventing the code to compile (I'm able to compile it and I can assure you your code is correct except for a detail that's irrelevant now).

    So, please, enter the compile command I posted before into a Terminal.

  7. #7
    Join Date
    Nov 2010
    Beans
    12
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: gtk programming problems

    I did run your command line in a terminal. Like I said earlier I've tried this with 3 different IDE's as well as the terminal.

    I've since done a full reinstall of glib, pango, atk, gtk+ as directed on the GTK+ website. Everything went perfectly.
    BUT...
    My error count has dropped to 25 errors

    So I'm making progress...
    But it still doesn't work!!!!! arg!!!
    I must still be missing an include file or there is a declare statement missing somewhere.

    **** Build of configuration Debug for project TestC ****

    make all
    Building file: ../Test.c
    Invoking: GCC C Compiler
    gcc -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Test.d" -MT"Test.d" -o"Test.o" "../Test.c"
    In file included from /usr/include/glib-2.0/glib/gtypes.h:35,
    from /usr/include/glib-2.0/glib/galloca.h:34,
    from /usr/include/glib-2.0/glib.h:32,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/glib/gmacros.h:47: warning: "G_GNUC_EXTENSION" redefined
    /usr/include/glib-2.0/glibconfig.h:38: note: this is the location of the previous definition
    In file included from /usr/include/glib-2.0/glib/gasyncqueue.h:34,
    from /usr/include/glib-2.0/glib.h:34,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/glib/gthread.h:271: error: expected specifier-qualifier-list before ‘GSystemThread’
    In file included from /usr/include/glib-2.0/glib/giochannel.h:35,
    from /usr/include/glib-2.0/glib.h:53,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/glib/gmain.h:136: error: expected ‘)’ before ‘pid’
    /usr/include/glib-2.0/glib/gmain.h:376: error: expected ‘)’ before ‘pid’
    /usr/include/glib-2.0/glib/gmain.h:509: error: expected declaration specifiers or ‘...’ before ‘GPid’
    /usr/include/glib-2.0/glib/gmain.h:510: error: expected declaration specifiers or ‘...’ before ‘GChildWatchFunc’
    /usr/include/glib-2.0/glib/gmain.h:513: error: expected ‘)’ before ‘pid’
    In file included from /usr/include/glib-2.0/glib.h:61,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/glib/gmessages.h:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    In file included from /usr/include/glib-2.0/glib.h:78,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/glib/gspawn.h:92: error: expected declaration specifiers or ‘...’ before ‘GPid’
    /usr/include/glib-2.0/glib/gspawn.h:105: error: expected declaration specifiers or ‘...’ before ‘GPid’
    /usr/include/glib-2.0/glib/gspawn.h:135: error: expected ‘)’ before ‘pid’
    In file included from /usr/include/glib-2.0/gobject/gobject.h:26,
    from /usr/include/glib-2.0/gobject/gbinding.h:31,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/gobject/gtype.h:1665: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1666: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1667: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1668: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1669: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1670: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1671: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1672: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    /usr/include/glib-2.0/gobject/gtype.h:1673: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
    In file included from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/gio/gioenums.h:630: error: ‘GLIB_SYSDEF_AF_INET’ undeclared here (not in a function)
    /usr/include/glib-2.0/gio/gioenums.h:631: error: ‘GLIB_SYSDEF_AF_INET6’ undeclared here (not in a function)
    /usr/include/glib-2.0/gio/gioenums.h:676: error: ‘GLIB_SYSDEF_MSG_OOB’ undeclared here (not in a function)
    /usr/include/glib-2.0/gio/gioenums.h:677: error: ‘GLIB_SYSDEF_MSG_PEEK’ undeclared here (not in a function)
    /usr/include/glib-2.0/gio/gioenums.h:678: error: ‘GLIB_SYSDEF_MSG_DONTROUTE’ undeclared here (not in a function)
    make: *** [Test.o] Error 1
    Last edited by solaris235; November 14th, 2010 at 09:34 PM.

  8. #8
    Join Date
    Feb 2010
    Location
    Silicon Valley
    Beans
    1,898
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: gtk programming problems

    Your code compiles fine for for me on 10.10 Maverick, written as a C file. The only additions needed were the appropriate pkg-config commands to set CFLAGS and LDFLAGS properly. As with the following makefile:
    Code:
    CC=gcc
    CFLAGS=-Wall -O0 -g3
    CFLAGS+=$(shell  pkg-config --cflags gtk+-2.0)
    LDFLAGS+=$(shell pkg-config --libs   gtk+-2.0)
    
    hello_gtk1: hello_gtk1.c
            $(CC) $(CFLAGS) $(LDFLAGS) -o hello_gtk1 hello_gtk1.c
    What version gcc are you using?
    Code:
    $ gcc --version
    gcc-4.4.real (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
    Here's how the make expanded (without CODE blocking so the line wraps):

    gcc -Wall -O0 -g3 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lm -lcairo -lpng12 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -o hello_gtk1 hello_gtk1.c

  9. #9
    Join Date
    Nov 2010
    Beans
    12
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: gtk programming problems

    Hey gmargo, thanks for the input...
    I'm using...

    Code:
    gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    I've used pkg-config in every way that it can be used,
    I tried your makefile,
    I tried your gcc command line,
    I still get the same errors.


    I know the C code it good. (everyone else can get it to compile and run)
    I know that gtk+ runs on my Maverick system. (Other apps that use gtk+ work fine)
    I know that gcc works fine.(I can compile and run other programs that don't use gtk)
    I know that g++ works fine.(for the same reason as gcc works)

    That leaves my development package as the problem
    Here are the libgtk2.0 packages that I have installed

    libgtk2.0-0
    libgtk2.0-doc
    libgtk2.0-0-dbg
    libgtk2.0-common
    libgtk2.0-bin
    libgtk2.0-dev
    libgtk2.0-cil

    installed versions of everything are 2.22.0-0ubuntu1 except libgtk2.0-cil ver: 2.10.12-1
    in case it matters I have Gimp Version 2.6.11-1~getdeb1~maverick installed as well.

    am I missing something or should I remove something ??????

  10. #10
    Join Date
    Feb 2010
    Location
    Silicon Valley
    Beans
    1,898
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: gtk programming problems

    Quote Originally Posted by solaris235 View Post
    make all
    Building file: ../Test.c
    Invoking: GCC C Compiler
    gcc -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Test.d" -MT"Test.d" -o"Test.o" "../Test.c"
    In file included from /usr/include/glib-2.0/glib/gtypes.h:35,
    from /usr/include/glib-2.0/glib/galloca.h:34,
    from /usr/include/glib-2.0/glib.h:32,
    from /usr/include/glib-2.0/gobject/gbinding.h:30,
    from /usr/include/glib-2.0/glib-object.h:25,
    from /usr/include/glib-2.0/gio/gioenums.h:30,
    from /usr/include/glib-2.0/gio/giotypes.h:30,
    from /usr/include/glib-2.0/gio/gio.h:28,
    from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-2.0/gdk/gdk.h:32,
    from /usr/include/gtk-2.0/gtk/gtk.h:32,
    from ../Test.c:8:
    /usr/include/glib-2.0/glib/gmacros.h:47: warning: "G_GNUC_EXTENSION" redefined
    /usr/include/glib-2.0/glibconfig.h:38: note: this is the location of the previous definition
    I find this error message very interesting.

    I do not have this file: /usr/include/glib-2.0/glibconfig.h. "locate glibconfig.h" on my system shows it at this path: /usr/lib/glib-2.0/include/glibconfig.h, and it does not contain the G_GNUC_EXTENSION definition. It is from the libglib2.0-dev package.

    So where did that file come from? Try "dpkg -S /usr/include/glib-2.0/glibconfig.h". And take a look at it. Is it a symbolic link? Or a misnamed copy of something else?

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •