Thread: [Linker error] undefined reference.(GTK, devcpp)

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    2

    Unhappy [Linker error] undefined reference.(GTK, devcpp)

    Yesterday I downloaded GTK package for Windows from http://gladewin32.sourceforge.net/modules/news/. During the installation it asked me if I wanted to integrate it with Devcpp, I said yes. When I opened Devcpp, There were new paths for GTK in "c includes " and "C++ includes". But when I try to compile this code

    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 says:
    [Linker error] undefined reference to `gtk_main'
    this is compile log:
    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "D:\programs\Dev-Cpp\misha\gtk-test.cpp" -o "D:\programs\Dev-Cpp\misha\gtk-test.exe" -g3 -I"d:\programs\GTK\INCLUDE" -I"d:\programs\GTK\INCLUDE\GLIB-2.0" -I"d:\programs\GTK\INCLUDE\PANGO-1.0" -I"d:\programs\GTK\INCLUDE\CAIRO" -I"d:\programs\GTK\INCLUDE\ATK-1.0" -I"d:\programs\GTK\INCLUDE\GTKGLEXT-1.0" -I"d:\programs\GTK\LIB\GTK-2.0\INCLUDE" -I"d:\programs\GTK\LIB\GLIB-2.0\INCLUDE" -I"d:\programs\GTK\LIB\GTKGLEXT-1.0\INCLUDE" -I"d:\programs\GTK\INCLUDE\LIBGLADE-2.0" -I"d:\programs\GTK\INCLUDE\LIBXML2" -I"D:\programs\GTK\include\gtk-2.0" -L"D:\programs\Dev-Cpp\lib" -g3
    C:\DOCUME~1\MIHAAM~1\LOCALS~1\Temp/ccSwaaaa.o(.text+0x2b): In function `main':
    D:/programs/Dev-Cpp/misha/gtk-test.cpp:13: undefined reference to `gtk_main'
    collect2: ld returned 1 exit status

    Execution terminated
    So, it does compile it, but can not link it then? What can be the problem? Help me please

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Look at the documentation, there should be a parameter you have to pass to the linker. The open up your project settings, go to parameters, there will be a list for linker, put the parameter there.

    Perhaps, try "-lgtk" if you can't find the correct parameter in the documentation.
    Last edited by SlyMaelstrom; 05-04-2006 at 03:37 PM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    2

    Lightbulb

    SlyMaelstrom - thanks, I got it to work! Actually, I had to include some dll-s from "lib" folder. GTK rocks! I liked it a lot, very simple and cool. I've been using Delphi for GUI-s(C++ - for console apps only). I found Glade much more functional.

    SlyMaelstrom - do you use GTK yourself? do you like it? I've heard Qt is also good, how do you think?

    and oh, I forgot to greet so, hello! nice forum, I'll be posting a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  3. Strange/false errors
    By Ganoosh in forum Windows Programming
    Replies: 8
    Last Post: 10-20-2005, 04:54 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM