First of all: are you aware that GTK2 is in deep maintenance mode and should not be used in newly written code?
GTK3 is tested using a static build, but GTK2 hasn’t been tested for that for a long time. Given that GTK2 is in deep maintenance mode, you’re basically on your own.
You need to use pkg-config --cflags --libs gtk+-2.0 to gather the compiler and linker flags needed to build GTK applications; that has not changed since 2001, and applies to any version of GTK from 2.0 onwards.
Yes, I know that GTK2 is obsolete. I am recently working on a open-source C project with a custom Makefile in Code::Blocks IDE. The project uses GTK2 code. But if compiles in about 6 seconds which is fast enough for me here. But for my Temp project I want to try GTK2 simplified code to ask about problems I face in coding the project.
I have followed my GTK2 example like following , is there anything to fix ?
IDE : Code::BLocks
Compiler : LLVM Clang
Build options : Append target options to project options.
It sounds like instead of asking how to compile GTK, you should be asking how to use Code::Blocks.
pkg-config is used during the configuration phase of compilation to determine the location of header files and libraries. It is commonly called as part of a build system, such as a configure script or a meson definition, though you can also use it from a command line like in the example you linked to. I don’t know how you incorporate that into Code::Blocks.