如何使用Dear ImGUI + SDL + SDLRenderer + OpenCv配置一个Cmake文件?

nuypyhwy  于 2022-11-11  发布在  其他
关注(0)|答案(1)|浏览(237)

我正在尝试为我的当前类创建一个使用ImGUI + SDL + SDLRenderer + OpenCv的CmakeLists.txt。

  1. .
  2. ├── CMakeLists.txt
  3. ├── imgui
  4.    ├── imconfig.h
  5.    ├── imgui.cpp
  6.    ├── imgui_demo.cpp
  7.    ├── imgui_draw.cpp
  8.    ├── imgui.h
  9.    ├── imgui_impl_sdl.cpp
  10.    ├── imgui_impl_sdl.h
  11.    ├── imgui_impl_sdlrenderer.cpp
  12.    ├── imgui_impl_sdlrenderer.h
  13.    ├── imgui_internal.h
  14.    ├── imgui_tables.cpp
  15.    ├── imgui_widgets.cpp
  16.    ├── imstb_rectpack.h
  17.    ├── imstb_textedit.h
  18.    ├── imstb_truetype.h
  19.    └── LICENSE.txt
  20. ├── main.cpp
  21. ├── Makefile
  22. └── testImages
  23. └── test001.png

我当前CMakeLists

  1. project(main)
  2. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  3. set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
  4. set(sources
  5. imgui/imconfig.h
  6. imgui/imgui.cpp
  7. imgui/imgui.h
  8. imgui/imgui_demo.cpp
  9. imgui/imgui_draw.cpp
  10. imgui/imgui_internal.h
  11. imgui/imgui_widgets.cpp
  12. imgui/imstb_rectpack.h
  13. imgui/imstb_textedit.h
  14. imgui/imstb_truetype.h
  15. imgui/imgui_impl_sdlrenderer.cpp
  16. imgui/imgui_impl_sdlrenderer.h
  17. imgui/imgui_impl_sdl.cpp
  18. imgui/imgui_impl_sdl.h
  19. )
  20. find_package(SDL2 REQUIRED)
  21. include_directories(${SDL2_INCLUDE_DIRS})
  22. find_package( OpenCV REQUIRED )
  23. add_executable( main main.cpp ${sources} )
  24. target_link_libraries( main ${OpenCV_LIBS} ${SDL2_LIBRARIES} )

但我得到了所有ImGUI函数的未定义引用:

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

目前我只想在linux中构建这个,所以我可以考虑以后的windows/ mac版本。
我做错了什么?

sbdsn5lh

sbdsn5lh1#

好的,就像drescherjm说的,我错过了一个文件imgui/imgui_tables.cpp。在我把这一行添加到CMakeLists.txt的集合中之后,它就工作了。

相关问题