“fatal error: gtk/gtk.h: No such file or directory” using make












14















I am trying to use make command to build. I am following this. I am compiling a code using GTK+2 and C language



hp@ubuntu:~/amhello$ make
make all-recursive
make[1]: Entering directory `/home/hp/amhello'
Making all in src
make[2]: Entering directory `/home/hp/amhello/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
main.c:3:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/home/hp/amhello/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hp/amhello'
make: *** [all] Error 2


this is the main.c code



#include<config.h>
#include<stdio.h>
#include<gtk/gtk.h>
void static call(GtkWidget *widget,gpointer data) {
g_print("%s n",(gchar*) data);
}
int main(int agrc, char *agrv) {
gtk_init(&agrc,&agrv);
GtkWidget *window,*button;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"one button");
button=gtk_button_new_with_label("hello world");
g_signal_connect(button,"clicked",G_CALLBACK(call),(gpointer) "hello world");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show_all(window);
gtk_main();
return (0);
}









share|improve this question

























  • did you even check if the file is there as it states? /gtk/gtk.h

    – Xylo
    Dec 29 '13 at 23:10













  • @Xylo dont know how to check. please tell me how i can check

    – osama
    Dec 29 '13 at 23:11











  • check if directory /usr/include/gtk-2.0 exists

    – Xylo
    Dec 29 '13 at 23:18








  • 1





    @Baraiam i have added the content of main.c

    – osama
    Dec 29 '13 at 23:36
















14















I am trying to use make command to build. I am following this. I am compiling a code using GTK+2 and C language



hp@ubuntu:~/amhello$ make
make all-recursive
make[1]: Entering directory `/home/hp/amhello'
Making all in src
make[2]: Entering directory `/home/hp/amhello/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
main.c:3:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/home/hp/amhello/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hp/amhello'
make: *** [all] Error 2


this is the main.c code



#include<config.h>
#include<stdio.h>
#include<gtk/gtk.h>
void static call(GtkWidget *widget,gpointer data) {
g_print("%s n",(gchar*) data);
}
int main(int agrc, char *agrv) {
gtk_init(&agrc,&agrv);
GtkWidget *window,*button;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"one button");
button=gtk_button_new_with_label("hello world");
g_signal_connect(button,"clicked",G_CALLBACK(call),(gpointer) "hello world");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show_all(window);
gtk_main();
return (0);
}









share|improve this question

























  • did you even check if the file is there as it states? /gtk/gtk.h

    – Xylo
    Dec 29 '13 at 23:10













  • @Xylo dont know how to check. please tell me how i can check

    – osama
    Dec 29 '13 at 23:11











  • check if directory /usr/include/gtk-2.0 exists

    – Xylo
    Dec 29 '13 at 23:18








  • 1





    @Baraiam i have added the content of main.c

    – osama
    Dec 29 '13 at 23:36














14












14








14


5






I am trying to use make command to build. I am following this. I am compiling a code using GTK+2 and C language



hp@ubuntu:~/amhello$ make
make all-recursive
make[1]: Entering directory `/home/hp/amhello'
Making all in src
make[2]: Entering directory `/home/hp/amhello/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
main.c:3:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/home/hp/amhello/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hp/amhello'
make: *** [all] Error 2


this is the main.c code



#include<config.h>
#include<stdio.h>
#include<gtk/gtk.h>
void static call(GtkWidget *widget,gpointer data) {
g_print("%s n",(gchar*) data);
}
int main(int agrc, char *agrv) {
gtk_init(&agrc,&agrv);
GtkWidget *window,*button;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"one button");
button=gtk_button_new_with_label("hello world");
g_signal_connect(button,"clicked",G_CALLBACK(call),(gpointer) "hello world");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show_all(window);
gtk_main();
return (0);
}









share|improve this question
















I am trying to use make command to build. I am following this. I am compiling a code using GTK+2 and C language



hp@ubuntu:~/amhello$ make
make all-recursive
make[1]: Entering directory `/home/hp/amhello'
Making all in src
make[2]: Entering directory `/home/hp/amhello/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
main.c:3:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/home/hp/amhello/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hp/amhello'
make: *** [all] Error 2


this is the main.c code



#include<config.h>
#include<stdio.h>
#include<gtk/gtk.h>
void static call(GtkWidget *widget,gpointer data) {
g_print("%s n",(gchar*) data);
}
int main(int agrc, char *agrv) {
gtk_init(&agrc,&agrv);
GtkWidget *window,*button;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"one button");
button=gtk_button_new_with_label("hello world");
g_signal_connect(button,"clicked",G_CALLBACK(call),(gpointer) "hello world");
gtk_container_set_border_width(GTK_CONTAINER(window),10);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show_all(window);
gtk_main();
return (0);
}






compiling gtk make






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 38 mins ago









Community

1




1










asked Dec 29 '13 at 23:09









osamaosama

3513619




3513619













  • did you even check if the file is there as it states? /gtk/gtk.h

    – Xylo
    Dec 29 '13 at 23:10













  • @Xylo dont know how to check. please tell me how i can check

    – osama
    Dec 29 '13 at 23:11











  • check if directory /usr/include/gtk-2.0 exists

    – Xylo
    Dec 29 '13 at 23:18








  • 1





    @Baraiam i have added the content of main.c

    – osama
    Dec 29 '13 at 23:36



















  • did you even check if the file is there as it states? /gtk/gtk.h

    – Xylo
    Dec 29 '13 at 23:10













  • @Xylo dont know how to check. please tell me how i can check

    – osama
    Dec 29 '13 at 23:11











  • check if directory /usr/include/gtk-2.0 exists

    – Xylo
    Dec 29 '13 at 23:18








  • 1





    @Baraiam i have added the content of main.c

    – osama
    Dec 29 '13 at 23:36

















did you even check if the file is there as it states? /gtk/gtk.h

– Xylo
Dec 29 '13 at 23:10







did you even check if the file is there as it states? /gtk/gtk.h

– Xylo
Dec 29 '13 at 23:10















@Xylo dont know how to check. please tell me how i can check

– osama
Dec 29 '13 at 23:11





@Xylo dont know how to check. please tell me how i can check

– osama
Dec 29 '13 at 23:11













check if directory /usr/include/gtk-2.0 exists

– Xylo
Dec 29 '13 at 23:18







check if directory /usr/include/gtk-2.0 exists

– Xylo
Dec 29 '13 at 23:18






1




1





@Baraiam i have added the content of main.c

– osama
Dec 29 '13 at 23:36





@Baraiam i have added the content of main.c

– osama
Dec 29 '13 at 23:36










4 Answers
4






active

oldest

votes


















21














This means that you don't have the gtk headers to build stuff using GTK+. Is really weird that the error didn't showed up at ./configure step. To solve this just do:



sudo apt-get install libgtk2.0-dev


or libgtk-3-dev.



That should do it.






share|improve this answer


























  • i have compiled several codes using #include<gtk/gtk.h> library

    – osama
    Dec 29 '13 at 23:20











  • the problem is when i am trying to use command make

    – osama
    Dec 29 '13 at 23:22











  • can you add the relevant code then to see if is possible to reproduce?

    – Braiam
    Dec 29 '13 at 23:23











  • my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

    – osama
    Dec 29 '13 at 23:23













  • go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

    – osama
    Dec 29 '13 at 23:25



















8














sudo apt-get install build-essential gnome-devel


That is also needed so that you can do cool things like:



g++ main.cpp -o base `pkg-config --cflags --libs gtk+-3.0`


It allows you to use pkg-config to save a whole lot of time








share|improve this answer


























  • At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

    – Rui Pimentel
    Jan 19 '16 at 13:54





















2














Since you are using autotools to generate your Makefiles, you need to tell automake how to find the header and library dependencies of your project and incorporate them into the final Makefiles. This is not my area of expertise but I will try to point you in the right direction. Most of the following is based on the tutorial found at Using C/C++ libraries with Automake and Autoconf



First, you must modify the top level configure.ac file to add the Gtk-2.0 dependency. You can use the PKG_CHECK_MODULES macro to run pkg-config to find the corresponding include and library directives - it's good practice to check that pkg-config exists first, so we should add a PKG_PROG_PKG_CONFIG test as well. The bolded portions indicate what`s added, relative to the files in the original amhello tutorial that you started from.




AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
src/Makefile
])
dnl Test for pkg-config
PKG_PROG_PKG_CONFIG([0.22])

dnl Test for gtk+
PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10])

AC_OUTPUT


Then in your src/Makefile.am you can retrieve the CFLAGS and LIBS using the GTK identifier that you used in the PKG_CHECK_MODULES macro above




bin_PROGRAMS = hello
hello_SOURCES = main.c
AM_CPPFLAGS = ${GTK_CFLAGS}
hello_LDADD = ${GTK_LIBS}


When you re-run make, it should re-generate your src/Makefile with the appropriate -I include paths, -L library paths and libraries.






share|improve this answer
























  • you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

    – osama
    Dec 30 '13 at 2:14



















2














Gtk3 equivalent debian/ubuntu package is libgtk-3-dev






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f397432%2ffatal-error-gtk-gtk-h-no-such-file-or-directory-using-make%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    21














    This means that you don't have the gtk headers to build stuff using GTK+. Is really weird that the error didn't showed up at ./configure step. To solve this just do:



    sudo apt-get install libgtk2.0-dev


    or libgtk-3-dev.



    That should do it.






    share|improve this answer


























    • i have compiled several codes using #include<gtk/gtk.h> library

      – osama
      Dec 29 '13 at 23:20











    • the problem is when i am trying to use command make

      – osama
      Dec 29 '13 at 23:22











    • can you add the relevant code then to see if is possible to reproduce?

      – Braiam
      Dec 29 '13 at 23:23











    • my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

      – osama
      Dec 29 '13 at 23:23













    • go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

      – osama
      Dec 29 '13 at 23:25
















    21














    This means that you don't have the gtk headers to build stuff using GTK+. Is really weird that the error didn't showed up at ./configure step. To solve this just do:



    sudo apt-get install libgtk2.0-dev


    or libgtk-3-dev.



    That should do it.






    share|improve this answer


























    • i have compiled several codes using #include<gtk/gtk.h> library

      – osama
      Dec 29 '13 at 23:20











    • the problem is when i am trying to use command make

      – osama
      Dec 29 '13 at 23:22











    • can you add the relevant code then to see if is possible to reproduce?

      – Braiam
      Dec 29 '13 at 23:23











    • my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

      – osama
      Dec 29 '13 at 23:23













    • go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

      – osama
      Dec 29 '13 at 23:25














    21












    21








    21







    This means that you don't have the gtk headers to build stuff using GTK+. Is really weird that the error didn't showed up at ./configure step. To solve this just do:



    sudo apt-get install libgtk2.0-dev


    or libgtk-3-dev.



    That should do it.






    share|improve this answer















    This means that you don't have the gtk headers to build stuff using GTK+. Is really weird that the error didn't showed up at ./configure step. To solve this just do:



    sudo apt-get install libgtk2.0-dev


    or libgtk-3-dev.



    That should do it.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 26 '15 at 15:36

























    answered Dec 29 '13 at 23:17









    BraiamBraiam

    51.7k20136221




    51.7k20136221













    • i have compiled several codes using #include<gtk/gtk.h> library

      – osama
      Dec 29 '13 at 23:20











    • the problem is when i am trying to use command make

      – osama
      Dec 29 '13 at 23:22











    • can you add the relevant code then to see if is possible to reproduce?

      – Braiam
      Dec 29 '13 at 23:23











    • my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

      – osama
      Dec 29 '13 at 23:23













    • go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

      – osama
      Dec 29 '13 at 23:25



















    • i have compiled several codes using #include<gtk/gtk.h> library

      – osama
      Dec 29 '13 at 23:20











    • the problem is when i am trying to use command make

      – osama
      Dec 29 '13 at 23:22











    • can you add the relevant code then to see if is possible to reproduce?

      – Braiam
      Dec 29 '13 at 23:23











    • my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

      – osama
      Dec 29 '13 at 23:23













    • go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

      – osama
      Dec 29 '13 at 23:25

















    i have compiled several codes using #include<gtk/gtk.h> library

    – osama
    Dec 29 '13 at 23:20





    i have compiled several codes using #include<gtk/gtk.h> library

    – osama
    Dec 29 '13 at 23:20













    the problem is when i am trying to use command make

    – osama
    Dec 29 '13 at 23:22





    the problem is when i am trying to use command make

    – osama
    Dec 29 '13 at 23:22













    can you add the relevant code then to see if is possible to reproduce?

    – Braiam
    Dec 29 '13 at 23:23





    can you add the relevant code then to see if is possible to reproduce?

    – Braiam
    Dec 29 '13 at 23:23













    my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

    – osama
    Dec 29 '13 at 23:23







    my compilies perfectly when i compile it by using this command gcc main.c -o hello gtk-config --cflags --libs gtk+-2.0

    – osama
    Dec 29 '13 at 23:23















    go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

    – osama
    Dec 29 '13 at 23:25





    go to this link and you will understand what i am trying to do askubuntu.com/questions/397246/…

    – osama
    Dec 29 '13 at 23:25













    8














    sudo apt-get install build-essential gnome-devel


    That is also needed so that you can do cool things like:



    g++ main.cpp -o base `pkg-config --cflags --libs gtk+-3.0`


    It allows you to use pkg-config to save a whole lot of time








    share|improve this answer


























    • At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

      – Rui Pimentel
      Jan 19 '16 at 13:54


















    8














    sudo apt-get install build-essential gnome-devel


    That is also needed so that you can do cool things like:



    g++ main.cpp -o base `pkg-config --cflags --libs gtk+-3.0`


    It allows you to use pkg-config to save a whole lot of time








    share|improve this answer


























    • At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

      – Rui Pimentel
      Jan 19 '16 at 13:54
















    8












    8








    8







    sudo apt-get install build-essential gnome-devel


    That is also needed so that you can do cool things like:



    g++ main.cpp -o base `pkg-config --cflags --libs gtk+-3.0`


    It allows you to use pkg-config to save a whole lot of time








    share|improve this answer















    sudo apt-get install build-essential gnome-devel


    That is also needed so that you can do cool things like:



    g++ main.cpp -o base `pkg-config --cflags --libs gtk+-3.0`


    It allows you to use pkg-config to save a whole lot of time









    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 10 '16 at 22:27









    Karl Richter

    2,42983568




    2,42983568










    answered Jan 10 '16 at 20:16









    AlrickAlrick

    8111




    8111













    • At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

      – Rui Pimentel
      Jan 19 '16 at 13:54





















    • At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

      – Rui Pimentel
      Jan 19 '16 at 13:54



















    At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

    – Rui Pimentel
    Jan 19 '16 at 13:54







    At least in my case, I did not have to execute sudo apt-get install build-essential gnome-devel, and the second command seemed to work at first, but led to glib "No such file or directory" problems as well. Solution was more like: g++ `pkg-config --cflags gtk+-3.0` main.cpp -o base `pkg-config --libs gtk+-3.0`

    – Rui Pimentel
    Jan 19 '16 at 13:54













    2














    Since you are using autotools to generate your Makefiles, you need to tell automake how to find the header and library dependencies of your project and incorporate them into the final Makefiles. This is not my area of expertise but I will try to point you in the right direction. Most of the following is based on the tutorial found at Using C/C++ libraries with Automake and Autoconf



    First, you must modify the top level configure.ac file to add the Gtk-2.0 dependency. You can use the PKG_CHECK_MODULES macro to run pkg-config to find the corresponding include and library directives - it's good practice to check that pkg-config exists first, so we should add a PKG_PROG_PKG_CONFIG test as well. The bolded portions indicate what`s added, relative to the files in the original amhello tutorial that you started from.




    AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    AC_PROG_CC
    AC_CONFIG_HEADERS([config.h])
    AC_CONFIG_FILES([
    Makefile
    src/Makefile
    ])
    dnl Test for pkg-config
    PKG_PROG_PKG_CONFIG([0.22])

    dnl Test for gtk+
    PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10])

    AC_OUTPUT


    Then in your src/Makefile.am you can retrieve the CFLAGS and LIBS using the GTK identifier that you used in the PKG_CHECK_MODULES macro above




    bin_PROGRAMS = hello
    hello_SOURCES = main.c
    AM_CPPFLAGS = ${GTK_CFLAGS}
    hello_LDADD = ${GTK_LIBS}


    When you re-run make, it should re-generate your src/Makefile with the appropriate -I include paths, -L library paths and libraries.






    share|improve this answer
























    • you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

      – osama
      Dec 30 '13 at 2:14
















    2














    Since you are using autotools to generate your Makefiles, you need to tell automake how to find the header and library dependencies of your project and incorporate them into the final Makefiles. This is not my area of expertise but I will try to point you in the right direction. Most of the following is based on the tutorial found at Using C/C++ libraries with Automake and Autoconf



    First, you must modify the top level configure.ac file to add the Gtk-2.0 dependency. You can use the PKG_CHECK_MODULES macro to run pkg-config to find the corresponding include and library directives - it's good practice to check that pkg-config exists first, so we should add a PKG_PROG_PKG_CONFIG test as well. The bolded portions indicate what`s added, relative to the files in the original amhello tutorial that you started from.




    AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    AC_PROG_CC
    AC_CONFIG_HEADERS([config.h])
    AC_CONFIG_FILES([
    Makefile
    src/Makefile
    ])
    dnl Test for pkg-config
    PKG_PROG_PKG_CONFIG([0.22])

    dnl Test for gtk+
    PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10])

    AC_OUTPUT


    Then in your src/Makefile.am you can retrieve the CFLAGS and LIBS using the GTK identifier that you used in the PKG_CHECK_MODULES macro above




    bin_PROGRAMS = hello
    hello_SOURCES = main.c
    AM_CPPFLAGS = ${GTK_CFLAGS}
    hello_LDADD = ${GTK_LIBS}


    When you re-run make, it should re-generate your src/Makefile with the appropriate -I include paths, -L library paths and libraries.






    share|improve this answer
























    • you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

      – osama
      Dec 30 '13 at 2:14














    2












    2








    2







    Since you are using autotools to generate your Makefiles, you need to tell automake how to find the header and library dependencies of your project and incorporate them into the final Makefiles. This is not my area of expertise but I will try to point you in the right direction. Most of the following is based on the tutorial found at Using C/C++ libraries with Automake and Autoconf



    First, you must modify the top level configure.ac file to add the Gtk-2.0 dependency. You can use the PKG_CHECK_MODULES macro to run pkg-config to find the corresponding include and library directives - it's good practice to check that pkg-config exists first, so we should add a PKG_PROG_PKG_CONFIG test as well. The bolded portions indicate what`s added, relative to the files in the original amhello tutorial that you started from.




    AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    AC_PROG_CC
    AC_CONFIG_HEADERS([config.h])
    AC_CONFIG_FILES([
    Makefile
    src/Makefile
    ])
    dnl Test for pkg-config
    PKG_PROG_PKG_CONFIG([0.22])

    dnl Test for gtk+
    PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10])

    AC_OUTPUT


    Then in your src/Makefile.am you can retrieve the CFLAGS and LIBS using the GTK identifier that you used in the PKG_CHECK_MODULES macro above




    bin_PROGRAMS = hello
    hello_SOURCES = main.c
    AM_CPPFLAGS = ${GTK_CFLAGS}
    hello_LDADD = ${GTK_LIBS}


    When you re-run make, it should re-generate your src/Makefile with the appropriate -I include paths, -L library paths and libraries.






    share|improve this answer













    Since you are using autotools to generate your Makefiles, you need to tell automake how to find the header and library dependencies of your project and incorporate them into the final Makefiles. This is not my area of expertise but I will try to point you in the right direction. Most of the following is based on the tutorial found at Using C/C++ libraries with Automake and Autoconf



    First, you must modify the top level configure.ac file to add the Gtk-2.0 dependency. You can use the PKG_CHECK_MODULES macro to run pkg-config to find the corresponding include and library directives - it's good practice to check that pkg-config exists first, so we should add a PKG_PROG_PKG_CONFIG test as well. The bolded portions indicate what`s added, relative to the files in the original amhello tutorial that you started from.




    AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    AC_PROG_CC
    AC_CONFIG_HEADERS([config.h])
    AC_CONFIG_FILES([
    Makefile
    src/Makefile
    ])
    dnl Test for pkg-config
    PKG_PROG_PKG_CONFIG([0.22])

    dnl Test for gtk+
    PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10])

    AC_OUTPUT


    Then in your src/Makefile.am you can retrieve the CFLAGS and LIBS using the GTK identifier that you used in the PKG_CHECK_MODULES macro above




    bin_PROGRAMS = hello
    hello_SOURCES = main.c
    AM_CPPFLAGS = ${GTK_CFLAGS}
    hello_LDADD = ${GTK_LIBS}


    When you re-run make, it should re-generate your src/Makefile with the appropriate -I include paths, -L library paths and libraries.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 30 '13 at 2:01









    steeldriversteeldriver

    67.2k11108180




    67.2k11108180













    • you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

      – osama
      Dec 30 '13 at 2:14



















    • you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

      – osama
      Dec 30 '13 at 2:14

















    you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

    – osama
    Dec 30 '13 at 2:14





    you are a genius. i was just waiting for your answer because i knew you can give the appropriate answer. thanks :)

    – osama
    Dec 30 '13 at 2:14











    2














    Gtk3 equivalent debian/ubuntu package is libgtk-3-dev






    share|improve this answer




























      2














      Gtk3 equivalent debian/ubuntu package is libgtk-3-dev






      share|improve this answer


























        2












        2








        2







        Gtk3 equivalent debian/ubuntu package is libgtk-3-dev






        share|improve this answer













        Gtk3 equivalent debian/ubuntu package is libgtk-3-dev







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 27 '14 at 1:51









        ThorSummonerThorSummoner

        1,4511224




        1,4511224






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f397432%2ffatal-error-gtk-gtk-h-no-such-file-or-directory-using-make%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            GameSpot

            connect to host localhost port 22: Connection refused

            Getting a Wifi WPA2 wifi connection