Author Topic: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE  (Read 20740 times)

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« on: June 15, 2012, 02:53:33 am »
Compilation- GTK+ programs in Win32 environment 10.06.2012 SNK
--------------------------------------------------------------
(thanks © 2006-2007 Andrey Borovsky <anb @ symmetrica.net>):
------------------------------------------------------------

In Linux creation of programs with use of GTK library rather clearly and simply.
It is possible to use Code::Blocks together with Glade, is possible without Glade, and it is possible and without Code:: Blocks - to do everything in the gedit editor, and then to compile in the terminal.
But in Windows setup Code:: Blocks project for operation with the compiler gcc and GTK+ library  isn't so simple and clear.
Therefore I decided to compile programs examples using command line in KMD.EXE

hello c++ console example
-------------------------
1. write text in file main.cpp
Code
#include <cstdio>

int main()
{
   printf("Hello World !\nHello GCC !\nHello ALL !");   return 0;
}
2. open c:\Windows\system32\cmd.exe (console-analog) & write command
Code
g++ -o main_cpp main.cpp
3.
run in console compiled main_cpp.exe and see output:
Code
Hello World !
Hello GCC !
Hello ALL !

hello gcc console example
-------------------------
1. write text in file main.c
Code
#include <io.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main()
{
   printf("Hello World !\nHello GCC !\nHello ALL !");
   return 0;
}
2. open c:\Windows\system32\cmd.exe (console-analog) & write command
Code
C:\projects\GTK\testGCC>gcc -o main main.c
main.c:2:21: error: cstdlib.h: No such file or directory
main.c:3:20: error: cstdio.h: No such file or directory
main.c: In function 'main':
main.c:9: warning: incompatible implicit declaration of built-in function 'printf'
2a.
System-variable PATH is:
Code
C:\projects\GTK\testGCC>PATH
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\CodeBlocks\MinGW\bin
2b.
System-variable PATH shall be corrected - add next:
Code
C:\projects\GTK\testGCC>SET PATH=%PATH%;C:\GTK+\bin;C:\GTK+\lib;C:\GTK+\include;C:\GTK+\lib\pkgconfig
and next:
Code
C:\projects\GTK\testGCC>SET PATH=%PATH%;C:\Program Files\CodeBlocks\MinGW\lib;C:\Program Files\CodeBlocks\MinGW\include
System-variable PATH is corrected - see NOW:
Code
C:\projects\GTK\testGCC>PATH
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\CodeBlocks\MinGW\bin;C:\GTK+\bin;C:\GTK+\lib;C:\GTK+\include;C:\GTK+\lib\pkgconfig;C:\Program Files\CodeBlocks\MinGW\lib;C:\Program Files\CodeBlocks\MinGW\include
2c.
Code
C:\projects\GTK\testGCC>gcc -Wall -g main.c -o main_C
3.
run in console compiled main_C.exe and see output:
Code
Hello World !
Hello GCC !
Hello ALL !
-------------------------------------------------------------------------------

HelloGTK example - GTK-window (Solid nut or HARD CORE!!!):
----------------------------------------------------------
0. !ATTENTION! You shall have the installed package "GTK+ bounle for Win32"

1. write text in file helloGTK.c (from every sample - see Internet)
GTK-program has string:
Code
#include <gtk/gtk.h>
  <-- it is main problem for linking-compiling !!!

2. open c:\Windows\system32\cmd.exe (console-analog) & write command
Code
C:\projects\GTK\testGCC>gcc -o helloGTK helloGTK.c
(or maybe C:\projects\GTK\testGCC>gcc -o main main.c)
Code
helloGTK.c:2:21: error: gtk/gtk.h: No such file or directory
( !!! gtk/gtk.h - is problem !!!)
... ... ... and so on - many error-strings ...

2a. then write command
Code
C:\projects\GTK\testGCC>gcc -Wall -g helloGTK.c -o helloGTK
helloGTK.c:2:21: error: gtk/gtk.h: No such file or directory
( !!! gtk/gtk.h - is problem !!!)
... ... ... and so on - many error-strings ...

2b. then write Linux-lyke command
Code
C:\projects\GTK\testGCC>gcc -Wall -g helloGTK.c -o helloGTK `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
gcc: `pkg-config: No such file or directory
gcc: gtk+-2.0`: No such file or directory
gcc: `pkg-config: No such file or directory
gcc: gtk+-2.0`: No such file or directory
cc1.exe: error: unrecognized command line option "-fcflags"
cc1.exe: error: unrecognized command line option "-flibs"
2c.
(on HDD-drive exists C:\GTK+\lib\pkgconfig\  or maybe C:\Program Files\CodeBlocks\MinGW\lib\pkgconfig\)
Code
SET PATH=%PATH%;C:\GTK+\lib\pkgconfig
2c1. - check installed GTK+ libraries:
Code
C:\projects\GTK\testGCC>pkg-config --libs gtk+-2.0
-LC:/GTK+/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
2c2. - check installed GTK+ includes (flags):
Code
C:\projects\GTK\testGCC>pkg-config --cflags gtk+-2.0
-mms-bitfields -IC:/GTK+/include/gtk-2.0 -IC:/GTK+/lib/gtk-2.0/include -IC:/GTK+/include/atk-1.0 -IC:/GTK+/include/cairo -IC:/GTK+/include/gdk-pixbuf-2.0 -IC:/GTK+/include/pango-1.0 -IC:/GTK+/include/glib-2.0 -IC:/GTK+/lib/glib-2.0/include -IC:/GTK+/include -IC:/GTK+/include/freetype2 -IC:/GTK+/include/libpng14
2c3. run CMD.EXE  2c4. insert IN ONE STRING includes & libs and run command:
Code
gcc -Wall helloGTK.c -o helloGTK -mms-bitfields -IC:/GTK+/include/gtk-2.0 -IC:/GTK+/lib/gtk-2.0/include -IC:/GTK+/include/atk-1.0 -IC:/GTK+/include/cairo -IC:/GTK+/include/gdk-pixbuf-2.0 -IC:/GTK+/include/pango-1.0 -IC:/GTK+/include/glib-2.0 -IC:/GTK+/lib/glib-2.0/include -IC:/GTK+/include -IC:/GTK+/include/freetype2 -IC:/GTK+/include/libpng14 -LC:/GTK+/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
or if Your file named main.c
Code
gcc -Wall main.c -o main -mms-bitfields -IC:/GTK+/include/gtk-2.0 -IC:/GTK+/lib/gtk-2.0/include -IC:/GTK+/include/atk-1.0 -IC:/GTK+/include/cairo -IC:/GTK+/include/gdk-pixbuf-2.0 -IC:/GTK+/include/pango-1.0 -IC:/GTK+/include/glib-2.0 -IC:/GTK+/lib/glib-2.0/include -IC:/GTK+/include -IC:/GTK+/include/freetype2 -IC:/GTK+/include/libpng14 -LC:/GTK+/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
As a result in the current folder it is possible to see the file "helloGTK.exe" (or "main.exe") - that is windows32 working executable file.

2c5. run command helloGTK (or main):
Code
C:\projects\GTK\testGCC>helloGTK
You shall see a window of your GTK program.

That is all !!!
-------------------------------------------------------------------------------

PostScriptum:
GTK+ is free sotware
The free software in the Windows environment will have the price in the form of libraries which are necessary for putting to your program if you want that the program was executed on any other computer.
In Windows static compilation of the program with GTK libraries is almost impossible.
Therefore it is necessary to write down the following files in the folder of the program:
Code
libgtk-win32-2.0-0.dll
libgdk-win32-2.0-0.dll
libcairo-2.dll
libgdk_pixbuf-2.0-0.dll
libpangowin32-1.0-0.dll
libpangocairo-1.0-0.dll
libpangoft2-1.0-0.dll
libpango-1.0-0.dll
libgio-2.0-0.dll
libgobject-2.0-0.dll
libgthread-2.0-0.dll
libgmodule-2.0-0.dll
libglib-2.0-0.dll
libatk-1.0-0.dll
freetype6.dll
intl.dll
zlib1.dll
libpng14-14.dll
libgcc_s_dw2-1.dll
libfontconfig-1.dll
-------------------
All (20 files) size of: 12963 KB (!!!)
Without them no GTK program will work.
It is useful to familiarize with license conditions of GTK previously.

Download some examples at:
http://www.mediafire.com/?w9w485myfw8z3ib


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #1 on: June 15, 2012, 03:29:50 am »
Read
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Note: The above might not apply; but, since I read your post twice and still did not find a clear question. I have to go with the default link that I post.

Tim S.
« Last Edit: June 15, 2012, 03:34:03 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #2 on: June 15, 2012, 03:51:50 am »
I think the OP want to wrote a tutorial.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #3 on: June 15, 2012, 08:45:54 am »
I think the OP want to wrote a tutorial.
Yes, but a very bad one: Adding include path's to the system's PATH environment is completely bullshit.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #4 on: June 15, 2012, 03:21:29 pm »
I think the OP want to wrote a tutorial.
Thanks for your notes. It is pleasant to me to see responses of dear developers of Code:: Blocks.
No, it didn't begin the textbook/tutotial, it is an illustration of makeshift of a question of compilation of programs in which GTK+ libraries are used.
Probably not I one experience difficulties in the correct configuration of the project Code::Blocks.
Probably not I one write programs in plain C language (without ++).

After I read forum rules, I was ashamed to ask questions directly.
I do not think that developers of GTK + will want to hear my questions. After all in Linux these libraries normally work, and a porting to Windows - the minor task.
In rules of a forum that discussion of questions connected to the compiler is offtop is strictly specified.
Here I also don't know as well as whom to ask.

But I have a question also the response to it I didn't find neither at a forum nor in other places.
Here my question:
What lines are necessary in a configuration Code::Blocks project OS windows32 for operation with the compiler gcc and to GTK+ libraries and Cairo.
And also (that is very important) where in project settings such lines should be inserted, that compilation of the project was same successful as in OS Linux.
For this purpose I at the end of the message gave the reference to the file archive with examples.

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #5 on: June 15, 2012, 04:21:10 pm »
Read
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Note: The above might not apply; but, since I read your post twice and still did not find a clear question. I have to go with the default link that I post.

Tim S.
This page new and the useful didn't tell anything to me.
C ++ not my programming language, I write on plain-C
MSVC not my compiler, I use gcc

Humour - a fine thing. But I will make one specification: I don't know English for talk. Only that is necessary for computer technologies and programming.
in case of communication with you I use the program of computer transfer (Promt - http://www.translate.ru) therefore "the subtle English humour" in the original is unavailable to me.
If at answering my question there is knowledge and good will, ask a reality in responses.

One more specification: in Russian my response not is a roughness sign, only an efficiency sign.

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #6 on: June 15, 2012, 04:36:16 pm »
I think the OP want to wrote a tutorial.
Yes, but a very bad one: Adding include path's to the system's PATH environment is completely bullshit.
I didn't find the other/best mode of work in Windows with the compiler and a linker from command line.
Line #include <gtk/gtk.h> mandatory in all programs using gtk library and smart internal communications/links in package GTK+ demanded it.

Moreover: without it the program successfully compiled and executed in the environment of Code::Blocks isn't executed if it to launch from the directory ../projects/bin/debug/
It doesn't find libraries for dynamic binding.
« Last Edit: June 15, 2012, 04:48:54 pm by sklimkin »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #7 on: June 15, 2012, 05:28:24 pm »
read http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

Try putting this in other options
Code
`pkg-config --libs gtk+-2.0`
The values inside the tick marks are converted to the result of the command ran on the command line (cmd.exe). (I think this happens on CB project load).

If Compiler options, put it in other compiler option.
If Linker options, put it in other linker option.

Both the other options locations should be one entry per line.

Tim S.
« Last Edit: June 15, 2012, 05:35:58 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #8 on: June 15, 2012, 07:04:58 pm »
...why don't you simply start wiht he GTK tempklate we have in Code::Blocks, or use the GTK project wizard, present in Code::Blocks, too.

If unsure where to setup which options, this is explained in the WiKi and also the documentation (see my sig).

A general advise from my side: Try to compile at the command line first, this should be the same as in linux except you have to exchange the include / library path's and maybe adjust some linker flags. If that works, you know all parameters you have to use inside the IDE. In addition you have a good learning curve to understand the functionality of the compiler/linker.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #9 on: June 15, 2012, 09:10:20 pm »
...why don't you simply start wiht he GTK tempklate we have in Code::Blocks, or use the GTK project wizard, present in Code::Blocks, too.
... ... ...
In my "gtk4" example each window and each element of a window it is declared as GtkWidget.
Compilation in Code::Blocks shows it as errors.
Compilation of the same example from command line comes to the end successfully, there are only warnings.
I well understand that these discrepancies "sit" in GTK library, but there are they by operation in Code::Blocks.
Moreover: in case of compilation of this example from Code::Blocks under Linux warnings and the program were given out only was compiled, collected and it works.
I don't state any claims to developers of Code::Blocks, opposite - this development environment allowed me to pass quite easily from Windows + Pelles-C to Linux + GTK. I want to share the observations with other users.
Possibly it will be useful for them.
If the administration of a forum doesn't wish discussion of such subjects, I certainly will cease to write. Though the subject not absolutely offtop seems to me that.

I will tell it is more: even the Windows OS me doesn't interest in any way. But I want to understand: why nobody could port GTK library on WinCE/Mobile. certain successes developers have porting mingw-ce + winAPI-ce.
There is a porting of this library on HP iPAQ hx4700 type devices as a part of the Linux OS (for example Angstrom), but it is not known, how programs using GTK will work.
Here therefore I also decided to look at GTK operation at least in Win32.

Here is how the project configuration in CodeBlocks for Win32 gcc GTK at me today looks:
Quote
To make in Windows Code::Blocks WORKING cgg & GTK+ project write manually:
--------------------------------------------------------------------------
0. Select and insert ONLY NEXT settings/strings, all others must bee EMPTY
--------------------------------------------------------------------------
1. Menu -> Settings -> Compiler and debugger ...

1a. Selected compiler -> GNU GCC COmpiler

1b. -> Search directories -> Compiler
C:\CodeBlocks\MinGW\bin
C:\Gtk+\bin
C:\Gtk+\lib
C:\Gtk+\include
C:\Gtk+\include\gtk-2.0\gtk
C:\Gtk+\include\gtk-2.0\gdk
C:\Gtk+\include\cairo

   -> Search directories -> Linker
C:\CodeBlocks\MinGW\bin
C:\Gtk+\bin
C:\Gtk+\lib
C:\Gtk+\pkgconfig

   -> Search directories -> Resource compiler
C:\CodeBlocks\MinGW\bin

1c.   -> Toolchain executables
Compiler's installation directoty: C:\CodeBlocks\MinGW
   -> Toolchain executables -> Program Files
C compiler: gcc.exe
C++ compiler: g++.exe
Linker for dinamic libs: g++.exe
Linker for static libs: gprofs.exe (??? static-linking don't work at all !!!)
Debugger: gdb.exe
Resource compiler: windres.exe
Make program: mingw32-make.exe

1d.   -> Other settings
Compiler logging: Full command line (select if you wish)

2. Menu -> Settings -> Global variables ...
   -> Current variable: <New> add manually: gtk2 (for example)
   Building fields: base
C:\CodeBlocks\MinGW
   include
C:\CodeBlocks\MinGW\include
   lib
C:\CodeBlocks\MinGW\lib
   obj
C:\CodeBlocks\MinGW\lib (or leave empty)
   cflags
pkg-config --cflags gtk+-2.0
   lflags
pkg-config --libs gtk+-2.0

3. Menu -> Project -> build options...
In tree select ONLY <project-name>, not <Debug>, not <Release>
Project -> Project build options -> Compiler settings -> Other options:
-mms-bitfields

   -> Linker settings -> Other linker settings
`pkg-config --cflags gtk+-2.0`
`pkg-config --libs gtk+-2.0`

   -> Search directories -> Compiler
C:\GTK+\bin
C:\GTK+\lib
C:\GTK+\include
C:\GTK+\lib\pkgconfig
C:\GTK+\include\gtk-2.0
C:\GTK+\include\glib-2.0
C:\GTK+\lib\glib-2.0\include
C:\GTK+\include\pango-1.0
C:\GTK+\include\atk-1.0

!!! After all leave ALL fields in <Debug> & <Release> pages EMPTY !!!
---------------------------------------------------------------------

??? Maybe for Cairo need also ??? (NOW I don't know - test required):
   -> Search directories -> Linker
C:\GTK+\bin
C:\GTK+\lib
C:\GTK+\include
C:\GTK+\include\atk-1.0
C:\GTK+\include\cairo
C:\GTK+\include\fontconfig
C:\GTK+\include\gdk-pixbuf-2.0
C:\GTK+\include\gio-win32-2.0
C:\GTK+\include\glib-2.0
C:\GTK+\include\gtk-2.0
C:\GTK+\include\gtk-2.0\gtk
C:\GTK+\include\gtk-2.0\gdk
C:\GTK+\include\libpng14
C:\GTK+\include\pango-1.0
-------------------------------------------------

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #10 on: June 16, 2012, 05:58:22 am »
GTK Works for me; I used the CB GTK Wizard.

I then erased the CB Wizard Search Directory and Library list and added these lines

In other linker options:
`pkg-config --libs gtk+-2.0`

In "Compiler Settings" (Other Options)
`pkg-config --cflags gtk+-2.0`

I also had to added the bin folder containing pkg-config to the CB search path.
There is at least three ways to do that; I used Compiler Global Settings "additional paths"

The above also worked for me; Note, I had to remove my Vala installation because it interfered with the results of the  pkg-config command and the MinGW GCC Compiler I was using in Code::Blocks.


NOTE: If YOU continue to post without asking any questions; I will consider you to NOT want any help!!!

In English an questions end in a question mark "?".

NOTE: If you get errors post them.

Edit: The GTK I am using is http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip

Tim S.

 
« Last Edit: June 17, 2012, 12:18:54 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #11 on: June 17, 2012, 09:28:29 pm »
Thanks, Tim.

GTK Works for me; I used the CB GTK Wizard.
In other linker options:
`pkg-config --libs gtk+-2.0`
In "Compiler Settings" (Other Options)
`pkg-config --cflags gtk+-2.0`
The above also worked for me; Note, I had to remove my Vala installation because it interfered with the results of the  pkg-config command and the MinGW GCC Compiler I was using in Code::Blocks.

Quote
I also had to added the bin folder containing pkg-config to the CB search path.
There is at least three ways to do that; I used Compiler Global Settings "additional paths"
I have made all these things.
Compiler Global Settings "additional paths" - I do not find such bookmark.

Quote
NOTE: If YOU continue to post without asking any questions; I will consider you to NOT want any help!!!
In English an questions end in a question mark "?".
From my observations (and me 62 years) the question not always comes to an end with a question sign. But it is possible and so:
What it is necessary to specify to system that the executed file received in CodeBlocks was executed out of CodeBlocks environment, for example from windows-explorer???
Thus (I remind) it is a question of the program using the compiler gcc and libraries GTK+ in OS Windows.

To a question: GTK and PATH to include-files and libraries in Win32
---------------------------------------------------------------------
For "purity of experiment" has loaded project Code::Blocks Win32 "gtk4" in virtual machine VMware player Windows-XP.
In system all is installed by default:
C:\Program Files\CodeBlocks
C:\Gtk +
In a system variable:
PATH=C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; c:\Program Files\ATI Technologies\ATI.ACE\Core-Static; C:\FPC\2.6.0\bin\i386-Win32
The project which was compiled also a file gtk4.exe was executed how I have described in the previous message, now isn't compiled.
I think that it is result of absence in system variable PATH of such things as: C:\GTK+ C:\GTK+\lib and so on.

By reviewing of error messages Code::Blocks it was necessary will add in setting of the project the following:
   -> Search directories -> Compiler
    C:\Gtk+\lib\gtk-2.0\include
    C:\Gtk+\include\cairo

   -> Linker settings -> Link libraries:
    C:\Gtk+\lib\glib-2.0.lib
    C:\Gtk+\lib\gtk-win32-2.0.lib
    C:\Gtk+\lib\gdk-win32-2.0.lib
    C:\Gtk+\lib\gobject-2.0.lib

After this compiled-linked  executable gtk4.exe
At execution gtk4.exe
System error message - It was not possible to find components:
... ... libgdk-win32-2.0-0.dll not found. (C:\GTK+\bin)

and in C::B window "Logs and others -->  Build log" prints:
Checking for existence: C:\projects\codeblocks\gtk4\bin\Debug\gtk4.exe
Executing: "C:\projects\codeblocks\gtk4\bin\Debug\gtk4.exe"  (in C:\projects\codeblocks\gtk4\.)
Process terminated with status -1073741515 (0 minutes, 13 seconds) - in red color line

Quote
NOTE: If you get errors post them.
Edit: The GTK I am using is http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip
Lines above the citation just about errors.
gtk+-bundle_2.24.10-20120208_win32.zip - I also use this distribution kit.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #12 on: June 17, 2012, 11:06:02 pm »
Post the full build log (after turning on Full Logging). Do a re-build so I can see the full and complete build log.

It works for me; but, since you do NOT wish to do it the normal way or the way I suggested using pkg-config.
(Doing it with just the CB Wizard, I did have to add search folder.)
But, using the pkg-config works perfectly without any search folders in the project.
Doing both ways together at the same time means it is much harder to find the real point of failure.

I consider you working on your own; I will check this thread from time to time; But, since it is no problem in Code::Blocks.
It is really your lack of Using Code::Blocks combined with a communication issue that is the problem.

NOTE: This thread is NOW going off topic for the Code::Blocks site; so, it could be locked at any time.

The sample code works perfectly for me. Added to post because I have no idea what code you are compiling.

Code
#include <stdlib.h>
#include <gtk/gtk.h>

static void helloWorld (GtkWidget *wid, GtkWidget *win)
{
  GtkWidget *dialog = NULL;

  dialog = gtk_message_dialog_new (GTK_WINDOW (win), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "Hello World!");
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
  gtk_dialog_run (GTK_DIALOG (dialog));
  gtk_widget_destroy (dialog);
}

int main (int argc, char *argv[])
{
  GtkWidget *button = NULL;
  GtkWidget *win = NULL;
  GtkWidget *vbox = NULL;

  /* Initialize GTK+ */
  g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
  gtk_init (&argc, &argv);
  g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);

  /* Create the main window */
  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (win), 8);
  gtk_window_set_title (GTK_WINDOW (win), "Hello World");
  gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
  gtk_widget_realize (win);
  g_signal_connect (win, "destroy", gtk_main_quit, NULL);

  /* Create a vertical box with buttons */
  vbox = gtk_vbox_new (TRUE, 6);
  gtk_container_add (GTK_CONTAINER (win), vbox);

  button = gtk_button_new_from_stock (GTK_STOCK_DIALOG_INFO);
  g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (helloWorld), (gpointer) win);
  gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);

  button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  g_signal_connect (button, "clicked", gtk_main_quit, NULL);
  gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);

  /* Enter the main loop */
  gtk_widget_show_all (win);
  gtk_main ();
  return 0;
}

Tim S.
« Last Edit: June 17, 2012, 11:19:53 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #13 on: June 17, 2012, 11:23:28 pm »
I think that it is result of absence in system variable PATH of such things as: C:\GTK+ C:\GTK+\lib and so on.

You NEED to have the C:\GTK+\bin folder in the System Path.

You NEED to have a working MinGW GCC C Compiler or other C Compiler installed.

If NOT using a MinGW GCC C Compiler, STATE that!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sklimkin

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #14 on: June 18, 2012, 02:44:58 pm »
You NEED to have the C:\GTK+\bin folder in the System Path.
You NEED to have a working MinGW GCC C Compiler or other C Compiler installed.
If NOT using a MinGW GCC C Compiler, STATE that!

Tim S.

Hello, Tim.
Thanks for attention and the detailed answer.
I have written you the answer with a result illustration, but it will explicitly overload a subject. Therefore has packed it into archive and I give the reference for downloading.
http://www.mediafire.com/?ayau3adanvccqbc

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Code::Blocks and GTK+ compile-link in Windows over KMD.EXE
« Reply #15 on: June 18, 2012, 04:18:50 pm »
You NEED to post on a site that Support GTK; I see no Code::Blocks problem.

Wrote middle level directions to use GTK with Code::Blocks here.

http://forums.codeblocks.org/index.php/topic,16468.msg111739.html

Feel free to ask questions about those directions.

I am getting tired of trying to help you. Because you are NOT understanding what I tell you.
And, I feel that I am not understanding what you post.

Tim S.
« Last Edit: June 18, 2012, 06:08:07 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org