GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Aug 21, 2014 6:00 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: gtk_pixbuf library not found
PostPosted: Tue Sep 25, 2012 4:23 am 
Offline

Joined: Tue Sep 25, 2012 4:16 am
Posts: 4
Location: India
Hello,

I tried compiling GTK2 library with a sample program. But unfortunately it is giving me linker error "-lgtk-pixbuff" not found. I have searched my entire PC but could not find this particular file, neither in GTK3.4.

So, please advice me a solution for it.


Thanks,
Embedded_Geek


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Tue Sep 25, 2012 7:47 am 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello.

Do you have gdk-pixbuf library installed? This is a separate library and while usually is installed along with GTK+ when package manager is involved, manual install will require you to build it on your own.

BTW, when I built stuff for testing in my home folder, I usually install glib, pango, atk, gdk-pixbuf and gtk+ in my local folder, since this way there is no conflict with system files.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Tue Sep 25, 2012 5:15 pm 
Offline

Joined: Tue Sep 25, 2012 4:16 am
Posts: 4
Location: India
I am using the following:

1) GTK+2.2
2) CodeBlocks IDE
3) Windows 7

My library contains a file "gdk_pixbuf-2.0" but NOT "gdk_pixbuf"

I tried compiling the following code:
Code:
#define GTK_ENABLE_BROKEN
#include <stdio.h>
#include <gtk/gtk.h>

void text_toggle_editable (GtkWidget *checkbutton,
            GtkWidget *text)
{
  gtk_text_set_editable (GTK_TEXT (text),
          GTK_TOGGLE_BUTTON (checkbutton)->active);
}

void text_toggle_word_wrap (GtkWidget *checkbutton,
             GtkWidget *text)
{
  gtk_text_set_word_wrap (GTK_TEXT (text),
           GTK_TOGGLE_BUTTON (checkbutton)->active);
}

void close_application( GtkWidget *widget,
                        gpointer   data )
{
       gtk_main_quit ();
}

int main( int argc,
          char *argv[] )
{
  GtkWidget *window,*box1, *box2, *hbox, *button, *check, *separator, *table, *vscrollbar, *text;
  GdkColormap *cmap;
  GdkColor color;
  GdkFont *fixed_font;

  FILE *infile;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_size_request (window, 600, 500);
  gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (close_application),
                    NULL);
  gtk_window_set_title (GTK_WINDOW (window), "Text Widget Example");
  gtk_container_set_border_width (GTK_CONTAINER (window), 0);

  box1 = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), box1);
  gtk_widget_show (box1);

  box2 = gtk_vbox_new (FALSE, 10);
  gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
  gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
  gtk_widget_show (box2);

  table = gtk_table_new (2, 2, FALSE);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
  gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0);
  gtk_widget_show (table);

  /* Create the GtkText widget */
  text = gtk_text_new (NULL, NULL);
  gtk_text_set_editable (GTK_TEXT (text), TRUE);
  gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (text);

  /* Add a vertical scrollbar to the GtkText widget */
  vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
  gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
          GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (vscrollbar);

  /* Get the system color map and allocate the color red */
  cmap = gdk_colormap_get_system ();
  color.red = 0xffff;
  color.green = 0;
  color.blue = 0;
  if (!gdk_color_alloc (cmap, &color)) {
    g_error ("couldn't allocate color");
  }

  /* Load a fixed font */
  fixed_font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-140-*-*-*-*-*-*");

  /* Realizing a widget creates a window for it,
   * ready for us to insert some text */
  gtk_widget_realize (text);

  /* Freeze the text widget, ready for multiple updates */
  gtk_text_freeze (GTK_TEXT (text));

  /* Insert some colored text */
  gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
         "Supports ", -1);
  gtk_text_insert (GTK_TEXT (text), NULL, &color, NULL,
         "colored ", -1);
  gtk_text_insert (GTK_TEXT (text), NULL, &text->style->black, NULL,
         "text and different ", -1);
  gtk_text_insert (GTK_TEXT (text), fixed_font, &text->style->black, NULL,
         "fonts\n\n", -1);

  /* Load the file text.c into the text window */

  infile = fopen ("text.c", "r");

  if (infile) {
    char buffer[1024];
    int nchars;

    while (1)
      {
   nchars = fread (buffer, 1, 1024, infile);
   gtk_text_insert (GTK_TEXT (text), fixed_font, NULL,
          NULL, buffer, nchars);

   if (nchars < 1024)
     break;
      }

    fclose (infile);
  }

  /* Thaw the text widget, allowing the updates to become visible */
  gtk_text_thaw (GTK_TEXT (text));

  hbox = gtk_hbutton_box_new ();
  gtk_box_pack_start (GTK_BOX (box2), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  check = gtk_check_button_new_with_label ("Editable");
  gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (check), "toggled",
                    G_CALLBACK (text_toggle_editable), text);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
  gtk_widget_show (check);
  check = gtk_check_button_new_with_label ("Wrap Words");
  gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
  g_signal_connect (G_OBJECT (check), "toggled",
                    G_CALLBACK (text_toggle_word_wrap), text);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
  gtk_widget_show (check);

  separator = gtk_hseparator_new ();
  gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
  gtk_widget_show (separator);

  box2 = gtk_vbox_new (FALSE, 10);
  gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
  gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
  gtk_widget_show (box2);

  button = gtk_button_new_with_label ("close");
  g_signal_connect (G_OBJECT (button), "clicked",
               G_CALLBACK (close_application),
               NULL);
  gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button);
  gtk_widget_show (button);

  gtk_widget_show (window);
  gtk_main ();
  return 0;
}


Attachments:
File comment: Error Screenshot
Error.jpg
Error.jpg [ 28.34 KiB | Viewed 752 times ]
Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Tue Sep 25, 2012 6:33 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

Hmm, where did you get your GTK+ from? GTK+-2.2 seems really old. Did you means 2.24 maybe? Anyhow, official bundle available from GTK+ site should work. There was some work needed in Code::Block's GTK+ template, since gdk-pixbuf is a separate library since 2.2x (I forgot what that x should be, but I think it's 4).

BTW, I wrote a tutorial on how to setup dev env on windows using Code::Blocks (available on this forum). If you followed my steps and got into trouble, please let me know. I'll boot into windows and check my installation instructions.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Wed Sep 26, 2012 12:28 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
The gdk-pixbuf-2.0 library you have is the ones that gtk+2 should be pulling in so it looks like there is some problem in the way the flags are being generated for compilation.
I'm not sure how things are on windows but on most linux machines using pkg-config is very common and chances are it is what you are using. In this case when you compile with using pkg-config to trace the dependencies on including the gtk+-2.0 libraries it will look at the gtk+-2.0.pc file which then says it requires gdk-${target}-2.0 (target for me is x11 on windows it is likely different). The gdk-${target}-2.0.pc file says it requires gdk-pixbuf-2.0 and finally the gdk-pixbuf-2.0.pc file says to set the libs flags as -lgdk_pixbuf-2.0
The fact that your error is giving -lgdk_pixbuf indicates that something may have gone wrong along the way. Either:
1: you are not compiling with gtk+-2.0 but another version.
2: the gtk library stack you installed has a bug in the way things are linked together in their .pc files (or whichever mechanism used for dependency tracing)
or 3: you have manually installed different parts of the library stack that are mutually incompatible (potentially through having different versions that don't run harmoniously together)

Could you tell us what command/makefile+configuration script you are using for compiling your program?


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Wed Sep 26, 2012 2:21 am 
Offline

Joined: Tue Sep 25, 2012 4:16 am
Posts: 4
Location: India
Quote:
Hi.

Hmm, where did you get your GTK+ from? GTK+-2.2 seems really old. Did you means 2.24 maybe? Anyhow, official bundle available from GTK+ site should work. There was some work needed in Code::Block's GTK+ template, since gdk-pixbuf is a separate library since 2.2x (I forgot what that x should be, but I think it's 4).

BTW, I wrote a tutorial on how to setup dev env on windows using Code::Blocks (available on this forum). If you followed my steps and got into trouble, please let me know. I'll boot into windows and check my installation instructions.

Cheers,
Tadej



Thanks Tadej. Could you please give me the link of the tutorial you have made for CodeBlocks. I am new to this forum so I am little rusty so could not yet locate the tutorial :(


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Wed Sep 26, 2012 2:27 am 
Offline

Joined: Tue Sep 25, 2012 4:16 am
Posts: 4
Location: India
Thanks GTK+ Guru for updating with the forum rules.

Regarding the commands, my IDE (codeblocks) does everything for me. I am not doing it myself. All I had to do was create a GTK project and to set the GTK library location. Then the IDE does the rest.

Waiting for a solution.


Regards,
Embedded_Geek


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Wed Sep 26, 2012 7:14 am 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

Here is the tutorial: http://www.gtkforums.com/viewtopic.php?f=3&t=8908. DO you think that this topic deserves to be pinned to the top of the forums or is installing GTK+ on Windows easy enough?

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: gtk_pixbuf library not found
PostPosted: Wed Sep 26, 2012 10:49 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
My vote being a non-windows user would be to pin it. I see a lot of questions with people having issues in installing and problems down the track, that I (and probably many other users who've had no issues with installation etc.) don't have the experience to address; but that the vast wealth of experience seems to be solely in your hands tadej. Installation may be easy enough but it seems to go wrong quite frequently due to the quantity of information on the gtk downloads site that goes over the top of the heads of most new developers. Having it up the top would mean that it has the visibility to be updated when new versions come in as well as being able to expand into related topics (e.g. producing the binaries you mentioned - personally I would also be interested in a tutorial on cross-compiling for windows when on a linux host).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: newguy and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group