Search code examples
cgccpathgtkpkg-config

gcc error message with gtk 2.0


My main.c:

#include <stdlib.h>
#include <gtk/gtk.h>

int main(int argc, char **argv)
{
    return EXIT_SUCCESS;
}  

I use:

gcc `pkg-config --cflags --libs libgtk+-2.0` -o tresor main.c  

but I get this error:

Package libgtk+-2.0 was not found in the pkg-config search path.  
Perhaps you should add the directory containing `libgtk+-2.0.pc'  
to the PKG_CONFIG_PATH environment variable  
No package 'libgtk+-2.0' found  
main.c:2:21: fatal error: gtk/gtk.h: No such file or directory  
 #include <gtk/gtk.h>
                     ^  
compilation terminated.  
make: *** [tresor] Error 1  

I checked libgtk2.0-dev and libgtk2.0-0 and it's already installed. I tried updating, upgrading removing and installing again. it doesn't work.


Solution

  • Just need to adjust the package name to gtk+-2.0 :

    gcc `pkg-config --cflags --libs gtk+-2.0` -o tresor main.c