Thread: problems with gtk+, and xlib

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    21

    problems with gtk+, and xlib

    First off, I'm kind of curious as to what other people use... gtk+? xlib?

    any suggestions? before I get too deep into one?

    Secondly, I was first trying to make some sample code compile using Xlib, I got it to compile, but I was getting link errors...

    So I tried to get some sample code working that used gtk+, I got it to compile finally, but I'm still getting similar link errors.....


    Such as:
    /tmp/ccIGk5Yw.o: In function `create_bbox':
    /tmp/ccIGk5Yw.o(.text+0xd): undefined reference to `gtk_frame_new'
    /tmp/ccIGk5Yw.o(.text+0x20): undefined reference to `gtk_hbutton_box_new'
    /tmp/ccIGk5Yw.o(.text+0x2d): undefined reference to `gtk_vbutton_box_new'
    /tmp/ccIGk5Yw.o(.text+0x42): undefined reference to `gtk_container_get_type'
    /tmp/ccIGk5Yw.o(.text+0x50): undefined reference to `gtk_type_check_object_cast'
    /tmp/ccIGk5Yw.o(.text+0x5b): undefined reference to `gtk_container_set_border_width'
    /tmp/ccIGk5Yw.o(.text+0x6f): undefined reference to `gtk_container_get_type'
    /tmp/ccIGk5Yw.o(.text+0x7d): undefined reference to `gtk_type_check_object_cast'
    /tmp/ccIGk5Yw.o(.text+0x88): undefined reference to `gtk_container_add'
    /tmp/ccIGk5Yw.o(.text+0x9c): undefined reference to `gtk_button_box_get_type'
    /tmp/ccIGk5Yw.o(.text+0xaa): undefined reference to `gtk_type_check_object_cast'
    /tmp/ccIGk5Yw.o(.text+0xb5): undefined reference to `gtk_button_box_set_layout'

    These are only a few, but they are all similar to this, even the Xlib ones..... I don't know what this is telling me, can someone explain it? and give me some hints as to how I can fix the problem? I'm just trying to get SOMETHING that brings up a window so that I can learn and play with it from there....

    Thanks much,
    (: Ian

  2. #2
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    Hi!

    Try this:
    gcc mygtkprog.c -lgtk -lgdk -lglib -lm

    (maybe you need still some more libraries)

    alex

  3. #3
    Registered User Sunny's Avatar
    Join Date
    Nov 2001
    Posts
    101
    Hi there!

    i'm new in linux but i like it very much. Does anyone out there wanna give me a briefing on what exactly is Gtk?
    and where can i find a good enviornment for compiling C++ programs. I mean, this gcc thing is really killing. I am using right now a Borland 3.1 compiler because i am working in DOS.




    Thanks.


    Sunny.
    Yes...YES!!! I did it! Ha ha ha...I'm king of the world...No..No..please-wait-no...!!!!-- This program has performed an illegal operation AND WILL be shut down....Ack-Choking..help...ack..

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    9
    I had the same problem, took me a good time to figure out.

    type gtk-config --libs --cflags<ENTER> in the console.
    copy the output
    type cc
    paste the output

    what you have here is a command lying in the console wich calls the compiler with all the info gtk+ needs.

    this could look like this:
    cc -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib
    -L/usr/lib/gtk -lgtk -lglib -gdk

    (typed it from memory)

    now add to the command line the name of your file(s) and the program name like you do usually (file.c -o program e.g.)

    press <ENTER> and you are good to go!

    However, pasting this into the command line all the time is a tedious thing to do. You could set up an alias to do this automatically:

    alias cc='cc alltheflagsareputhere '

    this does the trick, type it into ~/.bashrc

    But rember, this doesn't work in a Makefile.

    There is also supposed to be possible to type:
    cc 'gtk-config --libs' 'gtk-config --cflags'
    to accomplish the same thing, but it's never work with me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Xlib Fullscreen and/or borderless
    By IsmAvatar2 in forum Linux Programming
    Replies: 0
    Last Post: 06-17-2008, 11:25 AM