User forums > General (but related to Code::Blocks)

How to Configure Code::Blocks GTK MinGW Project

(1/3) > >>

stahta01:
Directions on my way of Configuring an Code::Blocks GTK MinGW GCC Project in Windows 7.
NOTE: I have never compiled any GTK project except for the CB Sample project.
NOTE: Used Code::Blocks 10.05 and MinGW GCC version 4.6.2 from I believe mingw.org

Steps are finished; I might need to add detail for each step; these directions use the GTK pkg-config command.

1. Download gtk+-bundle_2.24.10-20120208_win32.zip (all-in-one bundle) from http://www.gtk.org/download/win32.php
2. Extract in into a folder; in my case C:\apps\gtk+-bundle_2.24.10-20120208_win32
3. Add the bin folder to system path C:\apps\gtk+-bundle_2.24.10-20120208_win32\bin
4. Verify that the system path was updated and pkg-config works.
4a. Open command prompt box/window
4b. Enter command below

--- Code: ---pkg-config --cflags gtk+-2.0

--- End code ---
My results

--- Code: ----mms-bitfields -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/gtk-2.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/lib/gtk-2.0/include -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/atk-1.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/cairo -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/gdk-pixbuf-2.0 -IC:/appsgtk+-bundle_2.24.10-20120208_win32/include/pango-1.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/glib-2.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/lib/glib-2.0/include -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include -IC:/appsgtk+-bundle_2.24.10-20120208_win32/include/freetype2 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/libpng14

--- End code ---
5. Removed step 5; because it was not needed.
6. Use CB Wizard to create GTK sample project; I used "C:/apps/gtk+-bundle_2.24.10-20120208_win32" as GTK path
7. Edit the sample project to use pkg-config instead of the wizard search paths and libraries
7a. Clear the list of link libraries.
7b. Add `pkg-config --libs gtk+-2.0` to other linker options
7c. Clear search directories for Linker and Compiler
7d. Clear the option -mms-bitfields from Compiler settings other options
7e. Add `pkg-config --cflags gtk+-2.0` to Compiler settings other options

8. Build the sample project
Things to check if it failed to build
Did you remember to use the correct slanted single tick mark around the other option commands.
Try saving the project and restarting Code::Blocks.
Verify the full build log shows the correct paths.



Here's is my full build command; edit updated this code block. It was using the wrong paths.
(I had a prior gtk installation from a month ago and the pkg-config found it).

--- Code: ----------------- Build: Debug in testgtk ---------------

mingw32-gcc.exe -Wall -mms-bitfields -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/gtk-2.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/lib/gtk-2.0/include -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/atk-1.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/cairo -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/gdk-pixbuf-2.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/pango-1.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/glib-2.0 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/lib/glib-2.0/include -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/freetype2 -IC:/apps/gtk+-bundle_2.24.10-20120208_win32/include/libpng14     -g     -c C:\Users\tsta8844\Downloads\testgtk\main.c -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\testgtk.exe obj\Debug\main.o   -LC:/apps/gtk+-bundle_2.24.10-20120208_win32/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    

--- End code ---

Attached a 7-zip version of the modified project with main.c

Tim S.

sklimkin:
Once again thanks for your attention and angelic patience Tim!

I have understood all (anyway I so I think) from your explanations and an example.
This example successfully works in CodeBlocks: it is compiled, executed.

More difficult examples aren't compiled, but it most likely problems GTK+, instead of CodeBlocks.
I was surprised only with that these difficult examples were compiled out of CodeBlocks - from command line Windows.

I once again will adjust the project on these steps (1,2,3,...,8) and once again I will compile programs-examples.
But in it perhaps already there is no special necessity: it is necessary to talk to developers GTK+, you are right.

Sergey.

sklimkin:
I have anew configured CodeBlocks under recommendations Tim S.

Here an example of test program UIManager
The example is fulfilled after adjustment CodeBlocks specified in the previous message stahta01.
In archive of 4 directories (4 variants of an example):
1. linux CodeBlocks
2. linux console
3. win32 CodeBlocks
4. win32 console

The example is taken from the old textbook on GTK, but the program after an output remained in memory.
Therefore I a little it have corrected and have added the code for switching demonstration between windows and and an output of the most simple in GTK MessageBox.
Compilation win32 console hasn't turned out only because now in system variable PATH there are missing path's to important for compilation and the assembly to libraries.
I will correct a bit later.

But as a whole recommendations stahta01 are fulfilled also result is received.
See:
http://www.mediafire.com/?33yaa8d3coa6b0s
or attachment zip-file.

Once again thanks Tim S.

[attachment deleted by admin]

kvn:
thanks but i am getting a lot of errors after i build sample program..

stahta01:

--- Quote from: kvn on October 16, 2013, 04:56:56 pm ---thanks but i am getting a lot of errors after i build sample program..

--- End quote ---

You do realize error messages are information that you should post if you really want help, don't you?
(I suggest posting the first 12 errors and warnings; post at least the first 3 errors in case you have a lot of warnings.)

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
http://wiki.codeblocks.org/index.php?title=FAQ-Issues_and_Workarounds#Q:_I_posted_on_the_forums_that_Code::Blocks_was_not_working.2C_but_no_one_could_help_me.3F

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version