Compiling and Linking GTK 3 with C project on Ubuntu

前端 未结 2 1629
耶瑟儿~
耶瑟儿~ 2021-02-07 04:18

I believe this is not a duplicate question, I have seen all questions/answers before I post this question. I think I have a different situation here.

I use Ubuntu 12.04

相关标签:
2条回答
  • 2021-02-07 05:03

    You should compile with source file appearing before the libraries as gcc hello.c $(pkg-config --cflags --libs gtk+-3.0) -o hello, the reason being the behavior of linker i.e it does not link the libraries unless the symbols of that library is seen prior in compilation.
    Hope this helps!

    0 讨论(0)
  • 2021-02-07 05:12

    You could also include the gtk library directly into your project:

    1. In Eclipse expand: Project > Properties > C/C++ Build > Settings > Tool Settings > Cross GCC Linker > Libraries
    2. Set: Library search path (-L) to path to file "libgtk-n.so", with n as your version. After installing (apt-get install libgtk-3-dev) on Lubuntu this was "/usr/lib/x86_64-linux-gnu/" for me.
    3. Then add to Libraries (-l): gtk-n
    0 讨论(0)
提交回复
热议问题