Friday, May 31, 2013

Setup GTK project in Code::Blocks (windows 7)


Follow the following step to setup GTK project in Code::Blocks (windows 7)
step 1: Download gtk+-bundle_2.24.10-20120208_win32.zip (all-in-one bundle) from http://www.gtk.org/download/win32.php
step 2:  Extract it in c drive creating new directory or any other place. In my case C:\GTK is the directory where I extracted the zip file.
My extracted files looks like below.




step 3: Now Open Code::Blocks , create new project , from project wizard slect GTK project. And click go.

Give project name "GTKsample" or give name of your choice. And click next.

 Give path C:\GTK for GTK location where you extracted the zip file. And click Next.
And click Finish.

After creating gtk project you will see the sample program then build project, build must be successful.

step 4: This is last step, upto step 3 build project must be successful. When you try to run the project you will get message something .dll file (runtime library) missing like below image because we haven't given path for runtime library(.dll file). 

 For this goto the C:\GTK directories where you extracted the zip file. Open the bin folder only copy all the .dll file and paste it in your project directory GTKsample\bin\Debug\ with project executable file.

 In this method every time you create the project you have to keep all the .dll file with project executable file i.e (inside project \bin\Debug\ folder). If you don't want this then copy and paste all the .dll file from bin folder to C:\windows\system32 directory. 
If you completed the step 4 then the project. You must have successfully running project like below image.

Finally if you see the successfully running project like above image then you became successful to setup GTK project in Code::Blocks. If any problem occurs please comment below.

19 comments:

  1. Nice post. I was stuck with this. Helps me a lot. Thank u very much for this really helpful post.

    ReplyDelete
  2. I get "the path you entered seems valid but this wizard cann't locate the following GTK's include file: gtk.h in it

    ReplyDelete
    Replies
    1. You need to use GTK+ 2 as it doesn't work on GTK+ 3

      Delete
  3. I get "the path you entered seems valid but this wizard cann't locate the following GTK's include file: gtk.h in it.
    What is that? :(

    ReplyDelete
    Replies
    1. i had the same issue, it seems to be the GTK version, i try with GTK+ 3.6.4 (http://win32builder.gnome.org/gtk+-bundle_3.6.4-20130921_win32.zip) and got that error

      but with GTK+ 2.24 (http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip) i finally get things going

      Delete
  4. Yes, same error gtk 3.6.4.
    Of course, there is no solution to it.
    Typical problem with these backyard 'open source' projects.
    Now get Visual Studio.

    ReplyDelete
  5. Is there any way I can pack the .dll with the .exe? It's a pain if I have to send my "hello world" app to others with so many files!!

    ReplyDelete
  6. Thank you very much for help that worked for the GTK+ error ( "the path you entered seems valid but this wizard cann't locate the following GTK's include file: gtk.h in it.) THANKS MORPHEUS

    ReplyDelete
  7. Go in “C:\Program Files\CodeBlocks\share\CodeBlocks\templates\wizard\gtk”
    Edit (with admin right) the wizard.script file.
    Look for these lines:

    line 57 : if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("gtk-2.0") + wxFILE_SEP_PATH +_T("gtk"), _T("gtk.h"), _T("GTK's include")))

    line 64 : if (!VerifyLibFile(dir_nomacro_lib, _T("gtk-win32-2.0"), _T("GTK's")))

    line 116 : project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gtk-2.0"));

    line 123 : project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("gtk-2.0") + wxFILE_SEP_PATH + _T("include"));

    line 131 : project.AddLinkLib(_T("gtk-win32-2.0"));

    and change them like that:


    if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("gtk-3.0") + wxFILE_SEP_PATH +_T("gtk"), _T("gtk.h"), _T("GTK's include")))

    if (!VerifyLibFile(dir_nomacro_lib, _T("gtk-win32-3.0"), _T("GTK's")))

    project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gtk-3.0"));

    project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("gtk-3.0") + wxFILE_SEP_PATH + _T("include"));

    project.AddLinkLib(_T("gtk-win32-3.0"));

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Replies
    1. I know whats happen, before I have download GTK3, Now I use GTK2, is OK!

      Delete
  11. sk - Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping...
    Nothing to be done.

    ReplyDelete
  12. Thanks a lot man !!! Excellent job !!

    ReplyDelete
  13. Thanks a lot man !!! Excellent job !!

    ReplyDelete