Assuming you downloaded imgui to a place called $IMGUI_DIR and the file that contains your main function is main.cpp, your compile command line should look like the following: (Also note that the \ are just there to break up the command)
g++ main.cpp -o main \ $IMGUI_DIR/imgui*.cpp $IMGUI_DIR/backends/imgui_impl_glfw.cpp $IMGUI_DIR/backends/imgui_impl_opengl3.cpp \ -I $IMGUI_DIR -I $IMGUI_DIR/backends \ -lglfw -lGL
In order, you tell the compiler:
-
Where your code is and where to put the output
-
What Imgui code to include, namely the core library and the two backends you want to use
-
Where Imgui code should look for its headers
If all this sounds like a lot, know that you can simply build the example you linked and override IMGUI_DIR at compile time with make IMGUI_DIR=/path/to/imgui