Author Topic: [SOLVED]Gtk problem stops newbies (solved from 25 aug 2012 release)  (Read 7723 times)

Offline Hadomunt

  • Multiple posting newcomer
  • *
  • Posts: 11
Update: This problem is solved and beginning from the 25 aug 2012 release (8248) a fix is included.

I have encountered a bug/issue.
And found the solution and would like to bring this issue to the attention of the developers of Code::Blocks.
The issue is described and also how the developers can solve it. ;)
I have looked in the bug tracker, using gtk as search term but nothing relevant about this issue came up.
Developers: If you don't want to read it all, reading the how to fix it part should tell most of the important bits. 8)

- What is the problem?

Code::Blocks Gtk project wizard does not add all necessary gtk dependencies needed for the default project.
This is very bad since newbies are having a lot of problems solving this. :'(

- What did you do to when it happened?

Added a new project, chose gtk in the templates section, used gtk library, followed rest of wizard without modifying anything.
Clicked build and run.

- Can you reproduce it? How?
(Using Code::Blocks svn 8086 on win32 Vista)
Can be reproduced, steps necessary:
Start Code::Blocks
Choose GTK+ project, click Go button.
(If welcome page click Next >)
Fill in a title, doesn't matter much what name it is.
Click Next >
Add GTK's location.
Click Next >
Click Finish.

Click Build and run.

When building it should give the following error:
C:\Libs\gtk+-bundle_2.24.10-20120208_win32\include\gtk-2.0\gdk\gdkpixbuf.h|37|fatal error: gdk-pixbuf/gdk-pixbuf.h: No such file or directory|
(Code blocks opens gdkpixbuf.h and shows a red square on line 37 of that file.)
(The line of that file contains: #include <gdk-pixbuf/gdk-pixbuf.h> )

- What release of Code::Blocks are you using?
svn 8086
using Code::Blocks in windows with mingw.

- Which was the latest release that did not have this problem?
(It is a change in a library that causes codeblocks need to update scripts that work with that library.)

- What's going on?

The gtk team has made a new library named gdk-pixbuf-2.0 a necessary by default library.

gdk-pixbuf-2.0 was added in gtk+-bundle_2.22.0-20101016_win32 and later.
Before that version, gdk-pixbuf was not present.

The directory that needs to be included in the compiler search directories is:
<bundle install directory>\gtk+-bundle_2.22.0-20101016_win32\

- How to fix/solve?
The script for the gtk project wizard needs to be updated.
The script in question is:
<install dir>\CodeBlocks\share\CodeBlocks\templates\wizard\gtk\wizard.script

The gdk-pixbuf-2.0 library needs to be added.
(In the file after line 124.)
Code needs to be added that does a check on the relative path name and if it's there adds it.

Code that needs to be added:

if( IO.DirectoryExists(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk-pixbuf-2.0")) ){
    project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk-pixbuf-2.0"));

EDIT: tested the code and it works like it should.

I think it is best to do it this way instead of checking for version numbers because it is has better adaptability.
I have tested and every version of the gtk bundle that needs the gdk-pixbuf-2.0 library has that path.
The older versions of the gtk bundle that don't need gdk-pixbuf-2.0 don't have that path/folder/directory.

EDIT: Can somebody answer if it will be fixed or not?
Is fixed, see [ Bug #18665 ] gtk does not work with newer releases
« Last Edit: August 28, 2012, 03:50:35 pm by Hadomunt »