Author Topic: How to GTK+2.0 in CentOS 5  (Read 6622 times)

Offline cOde1

  • Single posting newcomer
  • *
  • Posts: 5
How to GTK+2.0 in CentOS 5
« 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
« Last Edit: September 19, 2012, 08:54:22 pm by cOde1 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to GTK+2.0 in CentOS 5
« Reply #1 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
(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!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to GTK+2.0 in CentOS 5
« Reply #2 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.

Offline cOde1

  • Single posting newcomer
  • *
  • Posts: 5
Re: How to GTK+2.0 in CentOS 5
« Reply #3 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. :)