News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to GTK+2.0 in CentOS 5

Started by cOde1, September 19, 2012, 08:49:58 PM

Previous topic - Next topic

cOde1

Hello,

I've installed gtk+2.0 in CentOS 5.
I can compie program from command prompt using gtk+ but don't know how to do it in Codeblocks.

After searching some threads I've added these codes into Codeblock's Settings > Compiler and Debugger settings > Other options
`pkg-config --libs --cflags gtk+-2.0`

and tried to compile a simple file which is compilable in terminal:
#include <gtk/gtk.h>

int main(int argc,char *argv[])
{
GtkWidget *window;

gtk_init(&argc,&argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);

gtk_main();

return 0;
}


It gives error message:
Quote/home/cOde1/Documents/gtk+/programs/window.o||In function `main':|
window.c|| undefined reference to `gtk_init'|
window.c|| undefined reference to `gtk_window_new'|
window.c|| undefined reference to `gtk_widget_show'|
window.c|| undefined reference to `gtk_main'|
||=== Build finished: 4 errors, 0 warnings ===|

Any help please.

Thanks.

Edit:
-------
Compiler is gcc:
$ rpm -q gcc
gcc-4.1.2-52.el5_8.1


oBFusCATed

Quote from: cOde1 on September 19, 2012, 08:49:58 PM
After searching some threads I've added these codes into Codeblock's Settings > Compiler and Debugger settings > Other options
`pkg-config --libs --cflags gtk+-2.0`
Definitely the wrong place.

Try to put `pkg-config --cflags gtk+-2.0`in Project -> Build options -> Compiler -> Other options
and `pkg-config --libs gtk+-2.0`in Project -> Build options -> Linker -> Other linker options
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Jenna

Don't use global compiler settings, if it is not absolutely necessary.

Better use the project settings.

Put `pkg-config --cflags gtk+-2.0` in the compilers other options and `pkg-config --libs gtk+-2.0` in the linkers other options.

cOde1

Hello,

I've removed that line from "global compiler" settings & added those in project's "build option" settings. Now, it's compiling files.

Thanks for the solution. :)