0

I'm trying to create a CmakeLists.txt that uses ImGUI + SDL + SDLRenderer + OpenCv for my current class.

.
├── CMakeLists.txt
├── imgui
│   ├── imconfig.h
│   ├── imgui.cpp
│   ├── imgui_demo.cpp
│   ├── imgui_draw.cpp
│   ├── imgui.h
│   ├── imgui_impl_sdl.cpp
│   ├── imgui_impl_sdl.h
│   ├── imgui_impl_sdlrenderer.cpp
│   ├── imgui_impl_sdlrenderer.h
│   ├── imgui_internal.h
│   ├── imgui_tables.cpp
│   ├── imgui_widgets.cpp
│   ├── imstb_rectpack.h
│   ├── imstb_textedit.h
│   ├── imstb_truetype.h
│   └── LICENSE.txt
├── main.cpp
├── Makefile
└── testImages
    └── test001.png

My current CMakeLists.

project(main)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
set(sources
    imgui/imconfig.h
    imgui/imgui.cpp
    imgui/imgui.h
    imgui/imgui_demo.cpp
    imgui/imgui_draw.cpp
    imgui/imgui_internal.h
    imgui/imgui_widgets.cpp
    imgui/imstb_rectpack.h
    imgui/imstb_textedit.h
    imgui/imstb_truetype.h
    imgui/imgui_impl_sdlrenderer.cpp
    imgui/imgui_impl_sdlrenderer.h
    imgui/imgui_impl_sdl.cpp
    imgui/imgui_impl_sdl.h
)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
find_package( OpenCV REQUIRED )
add_executable( main main.cpp ${sources} )
target_link_libraries( main ${OpenCV_LIBS} ${SDL2_LIBRARIES} )

But i get undefined references for all the ImGUI functions:

[ 12%] Linking CXX executable main
/usr/bin/ld: CMakeFiles/main.dir/imgui/imgui.cpp.o: in function `ImGuiListClipper_SeekCursorAndSetupPrevLine(float, float)':
imgui.cpp:(.text+0x60c6): undefined reference to `ImGui::TableEndRow(ImGuiTable*)'
/usr/bin/ld: CMakeFiles/main.dir/imgui/imgui.cpp.o: in function `ImGuiListClipper::Begin(int, float)':
imgui.cpp:(.text+0x62a3): undefined reference to `ImGui::TableEndRow(ImGuiTable*)'
/usr/bin/ld: CMakeFiles/main.dir/imgui/imgui.cpp.o: in function `ImGuiListClipper_StepInternal(ImGuiListClipper*)':
imgui.cpp:(.text+0x66d3): undefined reference to `ImGui::TableEndRow(ImGuiTable*)'
[...]

Currently i'm only trying to build this in linux, so I can think on the windows/ mac versions later.

What am I doing wrong?

  • It looks like `TableEndRow` is in `imgui_tables.cpp` and you are not using that as one of your sources: [https://github.com/ocornut/imgui/blob/master/imgui_tables.cpp](https://github.com/ocornut/imgui/blob/master/imgui_tables.cpp) – drescherjm Sep 29 '22 at 13:30
  • 1
    Okay... Maybe I was over-focusing on the Cmake part and didn't saw this. Thanks for helping me despite my silly question! Haha – Rafael Furlanetto Casamaximo Sep 29 '22 at 13:42

1 Answers1

0

Okay, so as said by drescherjm I missed one file imgui/imgui_tables.cpp. After I add this line to the set on the CMakeLists.txt it worked.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 04 '22 at 14:50