I've recently started coding with c++ and the project that im currently on requires imgui. so i set up the .h and .cpp libraries in a folder called "include" in the same folder as the source code. I'm currently trying to run the cpp in https://github.com/ocornut/imgui/tree/master/examples/example_glfw_opengl3 and compile it with gcc using gcc imgui.cpp -lstdc++ -lglfw -lGL -limgui
but i just get
/usr/bin/ld: cannot find -limgui
collect2: error: ld returned 1 exit status
yes i know there is a make file in the link but im using the file in another folder.
Assuming you downloaded imgui to a place called $IMGUI_DIR
and the file that contains your main function is main.cpp
, your compile commandline should look like the following: (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:
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