Advertisement Jump to content
Sign in to follow this  

undefined reference error when compiling gtk apps for linux

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

If you intended to correct an error in the post then please contact us.

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 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/ 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?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!