Menu

gtk+ in dev c++

bour1992
2009-04-24
2012-09-26
  • bour1992

    bour1992 - 2009-04-24

    Hello,
    Can you tell me how can i use the libraries of gtk+ in dev c++?
    Thanks in advance.

     
    • cpns

      cpns - 2009-04-25

      If you installed the package(s) the the "headers" are already put somewhere, but the compiler (or rather the preprocesor) needs to know where.

      I am surprised that the project template did not do this for you. Did you use the template? (was there even a template?). You say you did File->Project->New, but which project type did you select? I would expect at least one of the tabs in the dialog to have been populated with at least one new project template.

      You need to do a few things habitually. The first is to post the Compile Log rather than 'describe' the errors. It is quicker and easier for you, and more accurate. It also provides us more useful information about your project and installation than you might expect.

      The second is to tell use exactly what package or packages you installed - the link I posted had several GTK and GTK+ related packages, I doubt you needed to install them all, and hope that you didn't. That way someone can install them so that they can see what you should see. Unfortunately I no longer bother to install Dev-C++ so I may not be able to assist.

      Finally the "PLEASE READ BEFORE POSTING A QUESTION" thread has some general advice on using third-party libraries should there actually be no project template in the package (which would be unusual).

      Clifford

       
    • bour1992

      bour1992 - 2009-04-25

      I installed some packages from http://www.devpaks.org/category.php?category=GTK.
      The packages are:
      glib
      gtk
      pango
      atk
      cairo.

      After the installation a new template appeared in File->Project->New.
      I used THIS template (GTK TEMPLATE) to make a new application but i take the error gtk/gtk.h: no such file or directory and a lot of other errors from gtk functions.

       
    • cpns

      cpns - 2009-04-25

      Don't put a . at the end of links in this forum, it breaks them.

      The odd thing to me is that you originally asked about GTK+ but do not appear to have installed that. I have no idea what cairo might be , it does not appear on that page.

      It is possible that that DevPak is badly formed, but I doubt it.

      > but i take the error gtk/gtk.h: no such file or directory

      No No No NO NO! Did I not say POST THE COMPILE LOG!!

      Is your installation of Dev-C++ in the default location of c:\dev-cpp? Most DevPaks make that assumption and will break if not. Modification is simple, but it may be easier to install Dev-C++ in the expected location. Of course I would not have to ask if you had POSTED THE LOG!

      Clifford

       
    • Wayne Keen

      Wayne Keen - 2009-04-25

      NNote that the compile log is on the tab labeled "Compile Log",
      not the tab labeled compiler (you might be surprised how many ppeople don't see that), and the right mouse button brings up the copy menu.

      Wayne

       
    • bour1992

      bour1992 - 2009-04-27

      My Dev C++ is in the default location.

      The compile log is here:
      1 C:\Dev-Cpp\Projects\gtk\first\main.c gtk/gtk.h: No such file or directory.

      3 C:\Dev-Cpp\Projects\gtk\first\main.c variable or field `destroy' declared void

      3 C:\Dev-Cpp\Projects\gtk\first\main.c `GtkWidget' was not declared in this scope

      3 C:\Dev-Cpp\Projects\gtk\first\main.c `widget' was not declared in this scope

      4 C:\Dev-Cpp\Projects\gtk\first\main.c `gpointer' was not declared in this scope

      4 C:\Dev-Cpp\Projects\gtk\first\main.c initializer expression list treated as compound expression

      C:\Dev-Cpp\Projects\gtk\first\main.c In function `int main(int, char**)':

      9 C:\Dev-Cpp\Projects\gtk\first\main.c `GtkWidget' undeclared (first use this function)

      (Each undeclared identifier is reported only once for each function it appears in.)

      9 C:\Dev-Cpp\Projects\gtk\first\main.c `window' undeclared (first use this function)

      11 C:\Dev-Cpp\Projects\gtk\first\main.c gtk_init' undeclared (first use this function) 13 C:\Dev-Cpp\Projects\gtk\first\main.cGTK_WINDOW_TOPLEVEL' undeclared (first use this function)

      13 C:\Dev-Cpp\Projects\gtk\first\main.c `gtk_window_new' undeclared (first use this function)

      15 C:\Dev-Cpp\Projects\gtk\first\main.c `G_OBJECT' undeclared (first use this function)

      16 C:\Dev-Cpp\Projects\gtk\first\main.c `G_CALLBACK' undeclared (first use this function)

      16 C:\Dev-Cpp\Projects\gtk\first\main.c `NULL' undeclared (first use this function)

      16 C:\Dev-Cpp\Projects\gtk\first\main.c `g_signal_connect' undeclared (first use this function)

      20 C:\Dev-Cpp\Projects\gtk\first\main.c `gtk_widget_show' undeclared (first use this function)

      22 C:\Dev-Cpp\Projects\gtk\first\main.c `gtk_main' undeclared (first use this function)

      22 C:\Dev-Cpp\Projects\gtk\first\main.c At global scope:

      27 C:\Dev-Cpp\Projects\gtk\first\main.c variable or field `destroy' declared void

      27 C:\Dev-Cpp\Projects\gtk\first\main.c redefinition of `int destroy'

      3 C:\Dev-Cpp\Projects\gtk\first\main.c `int destroy' previously defined here

      27 C:\Dev-Cpp\Projects\gtk\first\main.c `GtkWidget' was not declared in this scope

      27 C:\Dev-Cpp\Projects\gtk\first\main.c `widget' was not declared in this scope

      28 C:\Dev-Cpp\Projects\gtk\first\main.c `gpointer' was not declared in this scope

      29 C:\Dev-Cpp\Projects\gtk\first\main.c expected ,' or;' before '{' token

      C:\Dev-Cpp\Projects\gtk\first\Makefile.win [Build Error] [main.o] Error 1

      and the default source:

      include <gtk/gtk.h>

      static void destroy( GtkWidget *widget,

                       gpointer   data );
      

      int main( int argc,

            char *argv[] )
      

      {

      GtkWidget *window;
      
      gtk_init (&amp;argc, &amp;argv);
      
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      
      g_signal_connect (G_OBJECT (window), &quot;destroy&quot;,
      
                G_CALLBACK (destroy), NULL);
      

      / TODO: type some code /

      gtk_widget_show  (window);
      
      gtk_main ();
      
      return 0;
      

      }

      static void destroy( GtkWidget *widget,

                       gpointer   data )
      

      {

      gtk_main_quit ();
      

      }

       
    • cpns

      cpns - 2009-04-27

      Good grief! It was very clearly explained by Wayne, and yet you still managed to post the "Compiler" tab text and not the "Compile Log" text - exactly the opposite of what he said. The log, the whole log, and nothing but the log.

       
      • Wayne Keen

        Wayne Keen - 2009-04-27

        And NEVER EVER EVER simply excerpt the errors from the compile log.

        Now, if you have a ton of errors, post from the start of the log, through the first 5 or so errors.

         
    • bour1992

      bour1992 - 2009-04-27

      I hope that now it is ok:

      Compiler: Default compiler

      Building Makefile: "C:\Dev-Cpp\Projects\gtk\first\Makefile.win"

      Exacution of make...

      make.exe -f "C:\Dev-Cpp\Projects\gtk\first\Makefile.win" all

      g++.exe -c main.c -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

      main.c:1:21: gtk/gtk.h: No such file or directory

      main.c:3: error: variable or field `destroy' declared void

      main.c:3: error: `GtkWidget' was not declared in this scope

      main.c:3: error: `widget' was not declared in this scope

      main.c:4: error: `gpointer' was not declared in this scope

      main.c:4: error: initializer expression list treated as compound expression

      main.c: In function `int main(int, char**)':

      main.c:9: error: `GtkWidget' undeclared (first use this function)

      main.c:9: error: (Each undeclared identifier is reported only once for each function it appears in.)

      main.c:9: error: `window' undeclared (first use this function)

      main.c:11: error: `gtk_init' undeclared (first use this function)

      main.c:13: error: `GTK_WINDOW_TOPLEVEL' undeclared (first use this function)

      main.c:13: error: `gtk_window_new' undeclared (first use this function)

      main.c:15: error: `G_OBJECT' undeclared (first use this function)

      main.c:16: error: `G_CALLBACK' undeclared (first use this function)

      main.c:16: error: `NULL' undeclared (first use this function)

      main.c:16: error: `g_signal_connect' undeclared (first use this function)

      main.c:20: error: `gtk_widget_show' undeclared (first use this function)

      main.c:22: error: `gtk_main' undeclared (first use this function)

      main.c: At global scope:

      main.c:27: error: variable or field `destroy' declared void

      main.c:27: error: redefinition of `int destroy'

      main.c:3: error: `int destroy' previously defined here

      main.c:27: error: `GtkWidget' was not declared in this scope

      main.c:27: error: `widget' was not declared in this scope

      main.c:28: error: `gpointer' was not declared in this scope

      main.c:29: error: expected ,' or;' before '{' token

      make.exe: *** [main.o] Error 1

      End of execution

       
    • cpns

      cpns - 2009-04-27

      OK, but where did the double line-spacing come from?

      Any way, now we van see that at line 21 of main.c teh pre-processor is looking for the file gtk/gtk.h, now for that to work teh gtk folder (with gtk.h in it) must exist in one of the locations specified by the -I<path> options on teh compiler command line (the reason you needed to post the log). So for it to work one of teh following must exist:

      C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include/gtk/gtk.h
      C:/Dev-Cpp/include/c++/3.4.2/backward/gtk/gtk.h
      C:/Dev-Cpp/include/c++/3.4.2/mingw32/gtk/gtk.h
      C:/Dev-Cpp/include/c++/3.4.2/gtk/gtk.h
      C:/Dev-Cpp/include/gtk/gtk.h

      Note that none of the above are necessarily appropriate locations for gtk.h, all I am saying is that that is where the preprocessor will look for the file.

      Now don't bother looking, because it is in none of those locations - if it were you would not have had the error message.

      What you need to do is find where the the gtk folder containing gtk.h was installed and add that to the include directory list. If it does not exist, then I suggest that you did not install it.

      When you have fixed that you will no doubt have a similar problem locating the library archives.

      > C:\Dev-Cpp\Projects\gtk\first\

      Don't keep your projects in teh Dev-C++ installation folder. It is a bad idea in any case and can cause build problems.

      Clifford

       
    • bour1992

      bour1992 - 2009-04-28

      I included the libraries from libs2.zip in the properties of dev c++ and i had the same errors.

      After that i included the headers of libs1.zip in C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include\gtk and much more errors appeared.
      (in lib1.zip i have all the files and folders is in C:\Dev-Cpp\lib)
      The errors are in the log file.

       
    • bour1992

      bour1992 - 2009-04-28

      Sorry i forgot the zip files.
      These are in http://www.2shared.com/file/5534181/5fc3bc1d/libs.html

       
    • cpns

      cpns - 2009-04-29

      Libraries are dealt with by the linker, your build has not yet got past the compilation stage, so linking is not yet an issue so the location of the libraries is not yet an issue.

      I am not about to download you libs.zip file; you tell me what is in it and where you got it from, and why I should be interested. All you need to do is follow instructions, and you are not doing that.

      Earlier you said you had installed the DevPak, so you should not have had to put the files anywhere other than where the DevPak left them. You certainly should not have moved them to C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include\ folder! That folder is for header files not library files (headers are not libraries, perhaps you meant headers). But more importantly that folder is for system headers to support a specific version of MinGW; you should not place third-party library or header files there.

      I thought I made it clear in my post, I was not suggesting that you put the headers there, I was merely stating that that was the list of locations that the compiler was looking. You needed to add to the list of places, not move the files!

      You are probably making things worse by making your own decisions about what to do rather than following instructions. Take this step by step. I expected you to:

      1) Find the installed location of the gtk.h file in a folder named gtk.

      2) Add the folder containing gtk\gtk.h to the include directory list.

      4) Attempt to build

      5) Post the log here without making any other changes. Telling us also the result of step (1) i.e. where is the file?

      Note that at (4) I am not necessarily expecting your build to work, but going it alone and making additional changes without providing the results here first, will screw up the results of the experiment and will diminish our ability to assist you in any meaningful manner. Stop being a moving target!

      And don't move anything. The DevPak is supposed to make it easy to use the libraries. Generally, if it is not easy, you are probably doing it wrong, and all that complicated fiddling is probably not the solution.

      Clifford

       
    • cpns

      cpns - 2009-04-24

      http://www.devpaks.org/category.php?category=GTK

      Also available through Tools->Check for Updates and Packages on the DevPaks.org repository.

      The chances are that the DevPak will install a project template (File->Project->New).

      Clifford

       
    • bour1992

      bour1992 - 2009-04-24

      I installed the packages for gtk but when i try to compile an application, the compiler write: gtk/gtk.h: no such file or directory..
      Where is the problem now?

       
      • Wayne Keen

        Wayne Keen - 2009-04-24

        (1) How did you install the packages?

        (2) When I get an error that indicates something is not found,the first thing I do is check and see if it is really there, but somewhere other than where the code is looking. Did you do a search to see if the header in question was there before posting your question? If you did,and didn't mention it in your question, then you are not thinking about how to ask a good question. If you didn't then you need to watch for the pattern of "See an error:Post a Question" reflex.

        Wayne

         
    • cpns

      cpns - 2009-04-24

      If the package included a project template and you used it as I suggested, all necessary tool settings should be applied.

      If you decided to go it alone, you will have to set up the necessary include paths, library paths, and linker options in the project set-up dialog.

      Clifford

       
    • bour1992

      bour1992 - 2009-04-25

      I installed the packages and i tried to create a gtk application from the menu in File->Project->New but I take this error.

      Where should i put the headers so that i can make an application in gtk?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.