Page 1 of 1

Problems using pkg-config (with GTK+) in codelite

Posted: Wed Sep 22, 2010 10:41 am
by malta
Well hi, my problem is that i want to use GTK+ library in my project, i made a very little program to check if i configured codelite settings in the right form, here is my code (very short):

Code: Select all

#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;
}
ok, i'm using pkg-config to link libraries, so using the last version of codelite (revision 4375) i put the next into the project->settings->compiler , in compiler options :

$(shell pkg-config --cflags --libs gtk+-2.0)

the i build the project but it gives me:

Code: Select all

----------Build Started--------
/bin/sh -c '"make"  -j 1 -f test_wsp.mk"'
----------Building project:[ testing - Debug ]----------
make[1]: Entering directory `/home/test/.codelite/hw/testing'
gcc -o ./Debug/testing ./Debug/main.o  "-L."   
./Debug/main.o: In function `main':
main.c:(.text+0x17): undefined reference to `gtk_init'
main.c:(.text+0x23): undefined reference to `gtk_window_new'
main.c:(.text+0x33): undefined reference to `gtk_widget_show'
main.c:(.text+0x38): undefined reference to `gtk_main'
collect2: ld returned 1 exit status
make[1]: *** [Debug/testing] Error 1
make[1]: Leaving directory `/home/test/.codelite/hw/testing'
make: *** [All] Error 2
----------Build Ended----------
0 errors, 0 warnings
i really don't realized why it doesn't work, any help will be very appreciated.

Thanks a lot.

Re: Problems using pkg-config (with GTK+) in codelite

Posted: Wed Sep 22, 2010 11:59 am
by eranif
There are 2 steps:
- compiling
- linking

The command:
$(shell pkg-config --cflags --libs gtk+-2.0)
includes the parameters required for both, however you are not building from a command line in a single step.

You need to break this command into 2:
project settings -> compiler -> compiler options: $(shell pkg-config --cflags gtk+-2.0)
project settings -> linker -> options: $(shell pkg-config --libs gtk+-2.0)

Eran

Re: Problems using pkg-config (with GTK+) in codelite

Posted: Wed Sep 22, 2010 10:54 pm
by malta
thank you eran, you save my life ;).

Cheers!