Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently decided to learn gtk+, so I installed the gtk3 developement package which contains all the necessary libraries, then I just wrote a simple program test which is supposed to display a gtk window simply and compiles it with the command below :

gcc `pkg-config --cflags --libs gtk+-3.0` main.c -o test

And the problem is at link time where I'm getting undefined reference to all the functions call :(

    /tmp/ccVQOyCZ.o: In function `main':
main.c:(.text+0x1f): undefined reference to `gtk_init'
main.c:(.text+0x29): undefined reference to `gtk_window_new'
main.c:(.text+0x43): undefined reference to `g_type_check_instance_cast'
main.c:(.text+0x64): undefined reference to `g_signal_connect_data'
main.c:(.text+0x70): undefined reference to `gtk_widget_show'
main.c:(.text+0x75): undefined reference to `gtk_main'
/tmp/ccVQOyCZ.o: In function `OnDestroy':
main.c:(.text+0x96): undefined reference to `gtk_main_quit'
collect2: ld returned 1 exit status

Voilà, if anyone has a solution...

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Try to reorder gcc options, that is, use:

gcc main.c -o test `pkg-config --cflags --libs gtk+-3.0`
share|improve this answer
    
Oh many thanks to you dilettant, now it works ! –  Pascal Hoareau Dec 30 '11 at 14:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.