# undefined reference error when compiling gtk apps for linux

This topic is 4147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

sorry if this is in the wrong forum; i wasn't sure if i should put it in For beginners or everything unix I just started reading the GTK+ tutorial at http://www.gtk.org/tutorial/ and i am stuck at the very beginning because i cannot compile the first example, a program that creates a window with gtk and does nothing. Everytime i try to compile it, gcc gives me this output:
/usr/local/lib/libpango-1.0.so: undefined reference to g_type_register_static_simple' collect2: ld returned 1 exit status [/QUOTE] I'm not sure, but I think the problem might be related to either a missing header file or a linker error because using synaptic package manager to download newer versions of Glib, GTK, and pango have not fixed this problem. Here is the source code:
[source lang = 'c']
#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;
}


and here is what i type into the command line to invoke gcc:
gcc base.c -o base pkg-config --cflags --libs gtk+-2.0` [/QUOTE] my distro is ubuntu, and im compiling with gcc. can someone please help me?