Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: cOde1 on September 19, 2012, 08:49:58 pm

Title: How to GTK+2.0 in CentOS 5
Post by: cOde1 on September 19, 2012, 08:49:58 pm
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
Code
`pkg-config --libs --cflags gtk+-2.0`

and tried to compile a simple file which is compilable in terminal:
Code
#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:
Code
$ rpm -q gcc
gcc-4.1.2-52.el5_8.1
Title: Re: How to GTK+2.0 in CentOS 5
Post by: oBFusCATed on September 19, 2012, 09:02:29 pm
After searching some threads I've added these codes into Codeblock's Settings > Compiler and Debugger settings > Other options
Code
`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
Title: Re: How to GTK+2.0 in CentOS 5
Post by: Jenna on September 19, 2012, 09:02:52 pm
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.
Title: Re: How to GTK+2.0 in CentOS 5
Post by: cOde1 on September 20, 2012, 11:51:56 am
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. :)