Find the answer to your Linux question:
Results 1 to 10 of 10
Hi I am using GTK+ on redhat linux.I am trying to run helloworld program given in tutorial. when I compile with command:gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+` I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    46

    compilation error with GTK+ application


    Hi

    I am using GTK+ on redhat linux.I am trying to run helloworld program given in tutorial.
    when I compile with command:gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+`

    I am getting this error:
    /tmp/ccoBxmgE.o(.text+0x80): In function `main':
    : undefined reference to `G_CALLBACK'
    /tmp/ccoBxmgE.o(.text+0x91): In function `main':
    : undefined reference to `G_OBJECT'
    /tmp/ccoBxmgE.o(.text+0x9a): In function `main':
    : undefined reference to `g_signal_connect'
    /tmp/ccoBxmgE.o(.text+0xac): In function `main':
    : undefined reference to `G_CALLBACK'
    /tmp/ccoBxmgE.o(.text+0xbd): In function `main':
    : undefined reference to `G_OBJECT'
    /tmp/ccoBxmgE.o(.text+0xc6): In function `main':
    : undefined reference to `g_signal_connect'
    /tmp/ccoBxmgE.o(.text+0x113): In function `main':
    : undefined reference to `G_CALLBACK'
    /tmp/ccoBxmgE.o(.text+0x124): In function `main':
    : undefined reference to `G_OBJECT'
    /tmp/ccoBxmgE.o(.text+0x12d): In function `main':
    : undefined reference to `g_signal_connect'
    /tmp/ccoBxmgE.o(.text+0x13b): In function `main':
    : undefined reference to `G_OBJECT'
    /tmp/ccoBxmgE.o(.text+0x14c): In function `main':
    : undefined reference to `G_CALLBACK'
    /tmp/ccoBxmgE.o(.text+0x15d): In function `main':
    : undefined reference to `G_OBJECT'
    /tmp/ccoBxmgE.o(.text+0x166): In function `main':
    : undefined reference to `g_signal_connect_swapped'
    collect2: ld returned 1 exit status


    I also tried to see pkg-config contains:
    [vineeta@vineeta sample]$ pkg-config --list-all
    gmodule-export-2.0 GModule - Dynamic module loader for GLib
    gmodule-2.0 GModule - Dynamic module loader for GLib
    glib-2.0 GLib - C Utility Library
    gobject-2.0 GObject - GLib Type, Object, Parameter and Signal Library
    gthread-2.0 GThread - Thread support for GLib
    gmodule-no-export-2.0 GModule - Dynamic module loader for GLib

    How to resolve these errors???

    Creating simple window with GTK is running sucessfully.......

    Regards
    vineeta7

  2. #2
    Linux Engineer aliov's Avatar
    Join Date
    Dec 2006
    Location
    Geneva,Beirut
    Posts
    1,078
    Quote Originally Posted by vineeta7 View Post
    Hi

    when I compile with command:gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+`
    use gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`

    Regards.
    Linux is not only an operating system, it's a philosophy.
    Archost.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    46
    Hi aliov

    tried with that also but getting same problem. Now its generates

    [vineeta@vineeta sample]$ gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`
    Package gtk+-2.0 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gtk+-2.0.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gtk+-2.0' found
    helloworld.c:1:21: gtk/gtk.h: No such file or directory
    helloworld.c:5: parse error before '*' token
    helloworld.c:11: parse error before "delete_event"
    helloworld.c:11: parse error before '*' token
    helloworld.c: In function `delete_event':
    helloworld.c:26: `TRUE' undeclared (first use in this function)
    helloworld.c:26: (Each undeclared identifier is reported only once
    helloworld.c:26: for each function it appears in.)
    helloworld.c: At top level:
    helloworld.c:30: parse error before '*' token
    helloworld.c: In function `main':
    helloworld.c:40: `GtkWidget' undeclared (first use in this function)
    helloworld.c:40: `window' undeclared (first use in this function)
    helloworld.c:41: `button' undeclared (first use in this function)
    helloworld.c:48: `GTK_WINDOW_TOPLEVEL' undeclared (first use in this function)
    helloworld.c:56: `NULL' undeclared (first use in this function)
    helloworld.c:80: `gtk_widget_destroy' undeclared (first use in this function)


    I have copy it from tutorial example.

    how to resolve this error???

    vineeta

  4. #4
    Linux Engineer aliov's Avatar
    Join Date
    Dec 2006
    Location
    Geneva,Beirut
    Posts
    1,078
    Hi,

    You told me you use RedHat , so i believe it's a old version wish contains only the gtk+1.2.x series , so the new version of gtk it seems to don't be installed . you can use gtk+1.2 but there is a lot of changes between the two version of this library .

    But be sure that you don't have the gtk+2.0 in the CD's of RedHat ,use your package manager to search , but i don't think it contained !

    so there is two possibilities
    1)- or to compile the new library from the source code ,wish i'm expecting to have a lot of compilation problems (so it's difficult ).

    2)- If you like RedHat , you can use the newer version of it , Fedora , so i think it's the only one way to get the newer versions of the devel tools of Linux .

    Let me know please what is your decision .

    Regards.
    Linux is not only an operating system, it's a philosophy.
    Archost.

  5. #5
    Just Joined!
    Join Date
    Sep 2007
    Posts
    46
    hi aliov

    Its working now. I set the env variables
    CPPFLAGS='-I/usr/include'
    LDFLAGS="-L/usr/lib"
    PKG_CONFIG_PATH="/usr/lib/pkgconfig"

    and compile with gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`

  6. #6
    Linux Engineer aliov's Avatar
    Join Date
    Dec 2006
    Location
    Geneva,Beirut
    Posts
    1,078
    Hi ,

    Well so Gtk+ 2.0 exist in RH , well i never used this Distro, but in any case you can have a look in the /usr/lib/pkgconfig to see what libraries are ready to be used by you and by other programs .

    Regards.
    Linux is not only an operating system, it's a philosophy.
    Archost.

  7. #7
    Just Joined!
    Join Date
    Sep 2007
    Posts
    46
    hi

    can u please tell me how to display value in gtk which is continously changing.I got a function which can display text but didnt find any function displaying value.

    I want to show the counter (value) and text with displaying sum.


    Please reply quickly its urgent

    Regards
    vineeta

  8. #8
    Linux Engineer aliov's Avatar
    Join Date
    Dec 2006
    Location
    Geneva,Beirut
    Posts
    1,078

    showing Values in GTK

    gchar * car = g_strdup_printf("%d", i);

    and here you can insert the car variable as a normal char * , inside any function of gtk , like gtk_set_text or gtk_text_buffer_insert.

    g_free(car); // if you need to save some memory .

    Tell me if this is enough , by the way it's better to make another threads each time you have something special in GTK, so other people can see them .

    Regards.
    Linux is not only an operating system, it's a philosophy.
    Archost.

  9. #9
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    Have you checked this thread?
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  10. #10
    Just Joined!
    Join Date
    Sep 2007
    Posts
    46
    yes aliov

    getting value in a GTK window.

    I am adding new thread .. please go through that

Posting Permissions

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