Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 7021  / 2 Years ago, tue, august 2, 2022, 11:26:43

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...


More From » 11.10

 Answers
3

Try to reorder gcc options, that is, use:



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

[#41222] Thursday, August 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tialmes

Total Points: 14
Total Questions: 108
Total Answers: 102

Location: Oman
Member since Thu, Jun 16, 2022
2 Years ago
;